POV-Ray : Newsgroups : povray.general : rand question Server Time
5 Nov 2024 18:22:11 EST (-0500)
  rand question (Message 1 to 10 of 37)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Tom Melly
Subject: rand question
Date: 11 Feb 2003 12:03:29
Message: <3e492ce1@news.povray.org>
How many numbers are in the rand stream before it repeats itself, or is this a
meaningless question?

--
#macro A(V,B,C,R)#while(B-256)#if(V-128/B>=0)sphere{0,.5translate<C-4R-1,9>
pigment{rgb<1-C/8R/2C/8>}}#local V=V-128/B;#end#local B=B*2;#local C=C+1;#
end#end A(234,1,0,2)A(85,1,0,1)A(81,1,0,0)light_source{-5 1}//Tom Melly


Post a reply to this message

From: Harold
Subject: Re: rand question
Date: 11 Feb 2003 12:22:57
Message: <3e493171$1@news.povray.org>
Repitition is inherent in randomness.

"Tom Melly" <tom### [at] tomandlucouk> wrote in message
news:3e492ce1@news.povray.org...
> How many numbers are in the rand stream before it repeats itself, or is
this a
> meaningless question?
>
> --
> #macro
A(V,B,C,R)#while(B-256)#if(V-128/B>=0)sphere{0,.5translate<C-4R-1,9>
> pigment{rgb<1-C/8R/2C/8>}}#local V=V-128/B;#end#local B=B*2;#local C=C+1;#
> end#end A(234,1,0,2)A(85,1,0,1)A(81,1,0,0)light_source{-5 1}//Tom Melly
>
>


Post a reply to this message

From: Tom Melly
Subject: Re: rand question
Date: 11 Feb 2003 12:28:32
Message: <3e4932c0$1@news.povray.org>
"Harold" <bai### [at] 3dculturecom> wrote in message
news:3e493171$1@news.povray.org...
> Repitition is inherent in randomness.

but isn't it a pseudo random string? - i.e. the repitition is predictable.


Post a reply to this message

From: Warp
Subject: Re: rand question
Date: 11 Feb 2003 13:16:45
Message: <3e493e0c@news.povray.org>
Tom Melly <tom### [at] tomandlucouk> wrote:
> How many numbers are in the rand stream before it repeats itself, or is this a
> meaningless question?

  Test it?

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Tom & Lu Melly
Subject: Re: rand question
Date: 11 Feb 2003 13:48:31
Message: <3e49457f$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3e493e0c@news.povray.org...

>   Test it?

I sort of am (I'm trying to get a specific sequence of numbers from a random
stream - don't ask).


Post a reply to this message

From: Doctor John
Subject: Re: rand question
Date: 11 Feb 2003 14:03:24
Message: <3e4948fc$1@news.povray.org>
"Tom & Lu Melly" <all### [at] tomandlucouk> wrote
>
> I sort of am (I'm trying to get a specific sequence of numbers from a
random
> stream - don't ask).
>

Wh.........

*realises he's just been told not to ask*

John
--
Run Fast
Run Free
Run Linux


Post a reply to this message

From: John VanSickle
Subject: Re: rand question
Date: 11 Feb 2003 14:20:42
Message: <3E494D23.7C164DC@hotmail.com>
Tom Melly wrote:
> 
> How many numbers are in the rand stream before it repeats itself, or
> is this a meaningless question?

#declare rsA=seed(0);
#declare rsB=seed(0);

#local sA=0;#local sB=-1;

#local cR=0;

#while(sA!=sB)

#local sA=rand(rsA);
#local sB=rand(rsB);
#local sB=rand(rsB);
#local cR=cR+1;
#end

#debug concat("Seed repeats after ",str(cR,0,0)," repetitions.\n"


Post a reply to this message

From: Vadim Sytnikov
Subject: Re: rand question
Date: 11 Feb 2003 14:25:54
Message: <3e494e42$1@news.povray.org>
"Tom Melly" <tom### [at] tomandlucouk> wrote:
> How many numbers are in the rand stream before it repeats itself, or is
this a
> meaningless question?

I assume we're talking about pseudo random numbers generators here, right?

The number you are talking about is known as the period of a generator and
is one of its most important properties... The two best generators that I
know are RANDMAR (with period 2^144; I use this one in my projects), and
R250 (with period 10^250, i.e. 1e251).

BTW, the "before it repeats itself" actually applies to the sub-sequences,
and not to individual numbers... RNGs' internals make it possible for many
different numbers to follow any given number. For instance, the following
sequence is easily possible with many RNGs:

1 2 3 4 2 9

Notice that 2 is first followed by 3, and then by 9. But if the period of
this generator is 6 :-), then 9 will be followed by 1 -- it is here that the
actual repetition takes place.

...

Oh well, I just figured out that that's p.g, so you probably meant POV-Ray
streams. Sorry for an off-topic post. Follow-ups to p.programming.


Post a reply to this message

From: Tom & Lu Melly
Subject: Re: rand question
Date: 11 Feb 2003 16:17:14
Message: <3e49685a$1@news.povray.org>
"John VanSickle" <evi### [at] hotmailcom> wrote in message
news:3E4### [at] hotmailcom...

> #debug concat("Seed repeats after ",str(cR,0,0)," repetitions.\n"

I'll take your word for it ;) Many thanks...


Post a reply to this message

From: Warp
Subject: Re: rand question
Date: 11 Feb 2003 17:52:44
Message: <3e497ebc@news.povray.org>
John VanSickle <evi### [at] hotmailcom> wrote:
> #while(sA!=sB)

  Are you completely sure that the same number will not appear twice
in the stream without looping back to the beginning?
  Naturally this might be so, but if the random number generator is made
even with the slightest quality, the same number can repeat many times
in the stream before it loops over.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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