Re: rand() pattern in texture?

From: codemagic (codemagic_at_gmail.com)
Date: 10/12/04


Date: 11 Oct 2004 23:02:57 -0700

Thanks you folks for your assistance!

I've experimented a bit more and found out the following:

1. The anomaly is 100% repeatable if I do rand() % c where c is a power
of 2. If c is not a power of 2 then I don't see the anomaly. Note that
the texture size I am using is a power of 2.
2. Shifting the result of rand() before doing the %c also seems to
work, e.g. (rand() >> 10) % 8 is OK. This is perhaps a better technique
because it doesn't restrict c.

Solved! Although I may also try the Mersenne Twister
(http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html) - if so I'll
let you know what I find.

Best Regards,

Tom



Relevant Pages

  • Re: Death of Jim Crow [was: Re: Bush Strums as New Orleans drowns]
    ... >> hypocrisy, in, let us say, the ideals of Rand, Wilder, and Patterson, is a ... Now Rand, to begin with, explicitly justifies an ... Rand's category of "power derived from reason" does not fit exactly ... >> Of the remaining people who identify themselves as libertarian who I ...
    (rec.arts.sf.fandom)
  • Re: Death of Jim Crow [was: Re: Bush Strums as New Orleans drowns]
    ... Now Rand, to begin with, explicitly justifies an ... I notice that you now talk about Objectivists and the phrase "valorize ... > remaining people who identify themselves as libertarian who I have ... > attracted to power. ...
    (rec.arts.sf.fandom)
  • Re: Efficient pseudo-random number generation
    ... than the plain use of rand(): ... m is the power of a prime. ... That is because raising a number x to a power n modulo a number m only takes ...
    (comp.lang.c)
  • Re: rand() % n Revisited
    ... power of two), that this is not an issue. ... worried about the fact that the rand() you are using has an output ... The C.L.C. FAQ about this gives extremely misleading advice on this ... The bias is small. ...
    (comp.lang.c)
  • Re: rand() % n Revisited
    ... I know you're not supposed to use "rand() % 1024" for instance, ... given that the argument is not a power of two (or near a power of ... repeatable patterns in the low-order "trits" ... ... bits or trits or quits or quints, ..., are not very good. ...
    (comp.lang.c)