Re: rand() pattern in texture?
From: Mensanator (mensanator_at_aol.compost)
Date: 10/10/04
- Next message: Phil Carmody: "Re: prime numbers"
- Previous message: David Ames: "Re: taking graduate level math classes at Boston MA - any recommendations"
- In reply to: codemagic: "rand() pattern in texture?"
- Next in thread: John M. Gamble: "Re: rand() pattern in texture?"
- Reply: John M. Gamble: "Re: rand() pattern in texture?"
- Messages sorted by: [ date ] [ thread ]
Date: 10 Oct 2004 15:44:49 GMT
>Subject: rand() pattern in texture?
>From: "codemagic" codemagic@gmail.com
>Date: 10/10/2004 8:24 AM Central Standard Time
>Message-id: <1097414643.721516.69860@f14g2000cwb.googlegroups.com>
>
>
>Hi,
>
>I am generating a texture of 1024 * 1024 pixels. I am using rand() % c
>to prefill it with some noise before adding some fractal noise.
>However, perhaps ten percent of the time I am seeing line anomalies in
>the prefilled texture.
>
>Do you think this is due to repetition in the sequence?
Or at least repetion in the portion of the random number that sets the pixel.
A random number's least significant bits are less reliable than the most
significant bits.
?Why can I only
>spot the pattern occasionally? Somebody suggested that not all seeds
>are equal - is that true? I srand on timeGetTime().
The random number generator has a certain period after which it repeats.
All a seed does is reposition your starting point within the period. If a
certain
area of the period gives you the line anomoly, then there are a million seeds
that will include that anomoly. If the period is larger than a million, than
there
will be seeds that don't include it (although they may show a different
anomoly).
>
>Can someone recommend a decent alternative implementation?
Lookup Mersenne Twister. The delelopers of the Python language didn't like
their original random number generator either and changed it to an
implementaion
of Mersenne Twister. Here's what the manual says about it:
<quote>
Python uses the Mersenne Twister as the core generator. It produces 53-bit
precision floats and has a period of 2**19937-1. The underlying implementation
in C is both fast and threadsafe. The Mersenne Twister is one of the most
extensively tested random number generators in existence. However, being
completely deterministic, it is not suitable for all purposes, and is
completely
unsuitable for cryptographic purposes.
</quote>
Do a Google search, you'll find C source code available. I know because I've
got a copy of it (but don't recall where I got it from). If you can't find it,
write back.
>Needs to be no slower.
Is a fast random number generator worth it if it produces crappy results?
Perl seems to be much faster than Python but Perl fails the DieHard test
whereas Python does not.
>
>Thanks a lot!
>
>Tom
-- Mensanator Ace of Clubs
- Next message: Phil Carmody: "Re: prime numbers"
- Previous message: David Ames: "Re: taking graduate level math classes at Boston MA - any recommendations"
- In reply to: codemagic: "rand() pattern in texture?"
- Next in thread: John M. Gamble: "Re: rand() pattern in texture?"
- Reply: John M. Gamble: "Re: rand() pattern in texture?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|