POV-Ray : Newsgroups : povray.general : random numbers Server Time
8 Aug 2024 10:22:14 EDT (-0400)
  random numbers (Message 11 to 20 of 20)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Mark Wagner
Subject: Re: random numbers
Date: 8 Feb 2001 03:56:03
Message: <3a825f23@news.povray.org>
Peter J. Holzer wrote in message ...
>On 2001-02-07 15:47, Tom Melly <tom### [at] tomandlucouk> wrote:
>>If it is a fixed sequence, how long is it?
>
>2^32.


I think it is actually (2^32)-2

--
Mark


Post a reply to this message

From: Warp
Subject: Re: random numbers
Date: 8 Feb 2001 07:34:39
Message: <3a82925f@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:
: next_rand[stream] = next_rand[stream] * 1812433253L + 12345L;

: which doesn't look particularly well-chosen to me.

  It depends on what you want to do, but basically you are right, it's not
excellent.
  There are better methods which give more randomness and much large periods.
  For example the C library function (not standard but found in most unix
compilers and perhaps others as well) for random() is described in the
following way:

     The random() function uses  a  nonlinear  additive  feedback
     random-number generator employing a default state array size
     of 31  long  integers  to  return  successive  pseudo-random
     numbers  in  the range from 0 to 2**31-1. The period of this
     random-number generator is approximately 16 x (2**31-1). The
     size  of  the  state  array  determines  the  period  of the
     random-number generator. Increasing  the  state  array  size
     increases the period.

  If I understand this correctly, it uses a whole array as seed value instead
of one integer. I suppose that this way more randomness is achieved and
a much larger period (16*(2^31-1) is pretty large).

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Geoff Wedig
Subject: Re: random numbers
Date: 8 Feb 2001 08:02:45
Message: <3a8298f5@news.povray.org>
Tom Melly <tom### [at] tomandlucouk> wrote:


> "Ken" <tyl### [at] pacbellnet> wrote in message
> news:3A8182D3.B378D2C3@pacbell.net...
>>
>>
>> Tom Melly wrote:
>> >
>>
>> > Also, is the random number sequence a fixed sequence, with the seed just
>> > controlling the point at which you join the sequence.
>>
>> Yes.
>>

> This resolves all the other questions.

>> > If it is a fixed sequence, how long is it?
>>
>> I don't know.
>>

> Except this one.

Well, most random number sequences these days use the 1/sec > heat death
system.  Ie, if you got one number a second, then the sequence would take
longer than the heat death of the universe to repeat.  If Pov's isn't this
good, I can get them the code for the Mersenne Twister, which is some
obscene multiple of the heat death criteria, and is also really good
randomly.  And it's *fast*, which is also a big plus.  We use it for high
end simulation where I work, where time is critical.

Geoff


Post a reply to this message

From: Ron Parker
Subject: Re: random numbers
Date: 8 Feb 2001 10:34:21
Message: <slrn985f3u.614.ron.parker@fwi.com>
On Thu, 8 Feb 2001 00:36:36 +0100, Alessandro Coppo wrote:
>*) Park Miller Minimal Standard
>http://htm4.ee.queensu.ca:8000/ling/minrng.html

This one looks good, but it doesn't have any sort of writeup.  Is there
another page that goes with this that might include copyright details?

>*) Mersenne Twister, currently the best known
>http://www.math.keio.ac.jp/~matumoto/emt.html,  period is 2**19937-1 it's
>not a typo... about 10**6000!!!

We can't use this one at this time as its license is GPL.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Jerry
Subject: Re: random numbers
Date: 8 Feb 2001 11:18:29
Message: <jerry-8E2C97.08170508022001@news.povray.org>
In article <slr### [at] fwicom>, ron### [at] povrayorg 
wrote:

>On Thu, 8 Feb 2001 00:36:36 +0100, Alessandro Coppo wrote:
>>*) Mersenne Twister, currently the best known
>>http://www.math.keio.ac.jp/~matumoto/emt.html,  period is 2**19937-1 it's
>>not a typo... about 10**6000!!!
>
>We can't use this one at this time as its license is GPL.

I saw the Mersenne Twister described in the latest WebTechniques. It 
looked pretty simple. GPL is a copyright, not a patent, as far as I 
know. Though I am not a lawyer, I'm pretty sure that recoding from an 
English description would not infringe on a copyright.

Jerry
-- 
http://www.hoboes.com/jerry/
"Give a man a fish and you feed him for a day. Teach him to fish, and you've
depleted the lake."--It Isn't Murder If They're Yankees
(http://www.hoboes.com/jerry/Murder/)


Post a reply to this message

From: Ron Parker
Subject: Re: random numbers
Date: 8 Feb 2001 11:55:48
Message: <slrn985jsn.61l.ron.parker@fwi.com>
On Thu, 08 Feb 2001 08:17:05 -0800, Jerry wrote:
>In article <slr### [at] fwicom>, ron### [at] povrayorg 
>wrote:
>
>>On Thu, 8 Feb 2001 00:36:36 +0100, Alessandro Coppo wrote:
>>>*) Mersenne Twister, currently the best known
>>>http://www.math.keio.ac.jp/~matumoto/emt.html,  period is 2**19937-1 it's
>>>not a typo... about 10**6000!!!
>>
>>We can't use this one at this time as its license is GPL.
>
>I saw the Mersenne Twister described in the latest WebTechniques. It 
>looked pretty simple. GPL is a copyright, not a patent, as far as I 
>know. Though I am not a lawyer, I'm pretty sure that recoding from an 
>English description would not infringe on a copyright.

True.  It would only be infringement to use the posted code.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Pete
Subject: Re: random numbers
Date: 8 Feb 2001 22:19:55
Message: <1229.438T1147T13094648PeterC@nym.alias.net>
Ron Parker wrote:

 <snippage>
>find a better PRNG for 3.5, since we've all seen some of the bad results
>you can get from the current one.

        I am curious: "bad results?"  Is the povray generator *that*
bad?  I mean, I have not done a rigorous statistical analysis of the
random output but it seems as good (as bad?) as any other random
number generator that I've used.  Whenever I get bad results, I use
a different seed.

        On thing I *have* noticed about the the random numbers that
pov kicks out is that they *seem* to be more like a stream of pink
"1/f" noise rather than the expected "white" noise: consecutive
values do not differ as much as one would expect (it's as if a "real"
random stream had been run through a mild low pass filter).  I have
read that for more "artistic" uses, this "1/f" noise yeilds more
"pleasing" or "natural" results.
        Or I could just be full of it.  :-)

        I suppose one could write a random number generator in the
pov langauge  (Arc 4 would work nicely), or another way would be
to just use four random streams, one stream picks which of the other
three streams' output to use.  You would be randomly switching
between 3 random streams.  Have not tried this.

Pete


Post a reply to this message

From: Ron Parker
Subject: Re: random numbers
Date: 8 Feb 2001 23:09:00
Message: <slrn986rav.68o.ron.parker@fwi.com>
On 7 Feb 2001 21:49:22 -0500, Pete wrote:
>Ron Parker wrote:
>
> <snippage>
>>find a better PRNG for 3.5, since we've all seen some of the bad results
>>you can get from the current one.
>
>        I am curious: "bad results?"  Is the povray generator *that*
>bad?  I mean, I have not done a rigorous statistical analysis of the
>random output but it seems as good (as bad?) as any other random
>number generator that I've used.  Whenever I get bad results, I use
>a different seed.

There's a high correlation between results, and it can lead to very
recognizable patterns.  I can find a reference to the original 
discussion here, if you're interested.

>        On thing I *have* noticed about the the random numbers that
>pov kicks out is that they *seem* to be more like a stream of pink
>"1/f" noise rather than the expected "white" noise: consecutive
>values do not differ as much as one would expect (it's as if a "real"
>random stream had been run through a mild low pass filter).  I have
>read that for more "artistic" uses, this "1/f" noise yeilds more
>"pleasing" or "natural" results.

Nope, the generator is the one I posted.  Nothing fractal about it.  It's
just not a very good generator.  The numbers (or at least the 12345) look
just a little arbitrary.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Warp
Subject: Re: random numbers
Date: 9 Feb 2001 09:55:45
Message: <3a8404f1@news.povray.org>
Jerry <jer### [at] acusdedu> wrote:
: I saw the Mersenne Twister described in the latest WebTechniques. It 
: looked pretty simple. GPL is a copyright, not a patent, as far as I 
: know. Though I am not a lawyer, I'm pretty sure that recoding from an 
: English description would not infringe on a copyright.

  It think that the problem with GPL is not that you can't use the source
code (all the contrary, GPL requires that the source code is available
and usable). The problem is that if you use the source code, the new code
you make must be GPL as well.

  LGPL would be different.

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Peter J  Holzer
Subject: Re: random numbers
Date: 9 Feb 2001 18:02:08
Message: <slrn988n56.85s.hjp-usenet@teal.h.hjp.at>
On 2001-02-09 04:09, Ron Parker <ron### [at] povrayorg> wrote:
>On 7 Feb 2001 21:49:22 -0500, Pete wrote:
>Nope, the generator is the one I posted. Nothing fractal about it. It's
>just not a very good generator. The numbers (or at least the 12345)
>look just a little arbitrary.

The example in the C standard also uses 12345 as the offset, but a
different multiplicator. Basically, for this kind of RNG, the three
numbers (the multiplicator, the offset and the modulus), must have a
GCD of 1[1], which is true for 1812433253 = 1289 * 1406077, 12345 = 3 *
5 * 823 and 4294967296 = 2 ^ 32). Then the sequence will produce all
non-negative numbers less than the modulus. Of course, some sequences
look more random than others ...

One problem with this type of RNG is than it produces "subsequences"
for each divisor of the modulus. For a modulus which is a power of two
this is particularly annoying since the lowest bit will run through a
sequence of two, the lowest two bits through a sequence of four etc.
Thus, to get random results, you should always take the highest bits,
not the lowest. Unlike C, Povray makes this "natural", by converting the
value to a double of range [0...1).

	hp

[1] My memory is a bit fuzzy here - correct me, if I'm wrong.

-- 
   _  | Peter J. Holzer    | All Linux applications run on Solaris,
|_|_) | Sysadmin WSR       | which is our implementation of Linux.
| |   | hjp### [at] wsracat      | 
__/   | http://www.hjp.at/ |	-- Scott McNealy, Dec. 2000


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.