POV-Ray : Newsgroups : povray.newusers : rand not producing random! Server Time
8 Jul 2024 02:57:41 EDT (-0400)
  rand not producing random! (Message 11 to 17 of 17)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Kenneth
Subject: Re: rand not producing random!
Date: 9 Jan 2010 15:25:01
Message: <web.4b48e504cc0023fa65f302820@news.povray.org>
"geogeo" <geo### [at] mecolcouk> wrote:
> I am using a rand generated value 'n' but the result is always the same. I've
> put in a text trace to output the value 'n' as follows:
>
> #declare R1 = seed(1);
> #declare n = rand(R1);

I remember that the concept of using seed() and rand() was a bit difficult to
grasp when I started out with POV-Ray (there is no real 'how-to' in the
documentation.)

Here's a simple example:

#declare R1 = seed(27);

pigment{color rgb <rand(R1),rand(R1),rand(R1)>}

Each rand is a different value--but those three different values will always be
the 'same', since they use the same seed() value. Change seed() and you get
three *new* and different rand() values.

Ken


Post a reply to this message

From: Christian Froeschlin
Subject: Re: rand not producing random!
Date: 9 Jan 2010 16:25:15
Message: <4b48f43b$1@news.povray.org>
Kenneth wrote:

> Each rand is a different value--but those three different values will always be
> the 'same', since they use the same seed() value. Change seed() and you get
> three *new* and different rand() values.

I actually thought I'd be clever and trick pov into providing
a seed based on the pixel value of a jittered 2x2 pixel image
rendered in a first pass ;) However, it seems the internally
used random numbers are not seeded by a timer either, so when
rendered after a restart the results were again predictable.


Post a reply to this message

From: Jim Holsenback
Subject: Re: rand not producing random!
Date: 10 Jan 2010 13:09:59
Message: <4b4a17f7@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote in message 
news:web.4b48e504cc0023fa65f302820@news.povray.org...
> I remember that the concept of using seed() and rand() was a bit difficult 
> to
> grasp when I started out with POV-Ray (there is no real 'how-to' in the
> documentation.)
>
> Here's a simple example:
>
> #declare R1 = seed(27);
>
> pigment{color rgb <rand(R1),rand(R1),rand(R1)>}
>
> Each rand is a different value--but those three different values will 
> always be
> the 'same', since they use the same seed() value. Change seed() and you 
> get
> three *new* and different rand() values.

After reading carefully this example in seems to be saying the same thing:

http://wiki.povray.org/content/Documentation:Reference_Section_2#Functions

I also started a talk page:

http://wiki.povray.org/content/Documentation_Talk:Reference_Section_2

Just in case you might think it could be better worded!

Jim


Post a reply to this message

From: Kenneth
Subject: Re: rand not producing random!
Date: 11 Jan 2010 06:20:00
Message: <web.4b4b054acc0023fa65f302820@news.povray.org>
"Jim Holsenback" <jho### [at] povrayorg> wrote:

> After reading carefully this example in seems to be saying the same thing:
>
> http://wiki.povray.org/content/Documentation:Reference_Section_2#Functions
>

Ah, so it does! :-)

I think the explanations given in the docs could probably be less 'technical',
so as to make more sense to newbies.

Here's how rand() begins:
"Returns the next pseudo-random number from the stream specified by the positive
integer I. You must call seed() to initialize a random stream before calling
rand()."

Egads, that's a lot of tech-speak. First off, it *kind of* sounds like the user
is--or needs to be--already privvy to the 'stream' he's looking for--i.e., "I
need the stream specified by the positive integer 27." Of course, we don't know
what the contents of that stream are (or even what a 'stream' is, if we're REAL
newbies!) so it all sounds confusing/mysterious/unknowable.

Next up is the arcane phrase, "You must call seed..."  Unless the newbie is
already familiar with programming, that word 'call' is rather mysterious. In POV
lingo, it would mean #declare *some variable name* = seed(32). (IF you already
know that, of course!)  Personally, I didn't have the faintest idea what 'call'
meant when I started out...and it made me feel quite 'out of my depth', as if
there was some secret code I had to decipher. Such little dead-end details as
these can be off-putting to a beginner.

Oh, and here's another, from seed:
"seed(I) Initializes a new pseudo-random stream with the initial seed value A."
A or I? What is A?? (Probably a typo, I know--but when one is fishing around for
the meaning of a difficult-to-grasp topic, such a little mystery adds to the
confusion.)

What strikes me about the POV documentation as a whole is that some sections are
written and described very clearly--from a 'humanistic' point of view; while
others seem to lifted verbatim from a programmer's handbook. Granted, the early
iterations of POV-Ray were probably meant only for knowledgeable programmers;
but the documentation is starting to show its age.

Ken


Post a reply to this message

From: Jim Holsenback
Subject: Re: rand not producing random!
Date: 11 Jan 2010 06:49:15
Message: <4b4b103b@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote in message 
news:web.4b4b054acc0023fa65f302820@news.povray.org...
> I think the explanations given in the docs could probably be less 
> 'technical',
> so as to make more sense to newbies.

Yes and you've made some valid points ....

Like I said:
http://wiki.povray.org/content/Documentation_Talk:Reference_Section_2

If you can come up with something clearer ....

Imagine that!! a chance to actually do something about a situation rather 
than point out flaws and expect someone else to fix it!!

Pardon the sarcasm there Ken ... no offence intended.

Jim


Post a reply to this message

From: Kenneth
Subject: Re: rand not producing random!
Date: 11 Jan 2010 17:15:00
Message: <web.4b4ba1a6cc0023fa65f302820@news.povray.org>
"Jim Holsenback" <jho### [at] povrayorg> wrote:

> If you can come up with something clearer ....
>
> Imagine that!! a chance to actually do something about a situation rather
> than point out flaws and expect someone else to fix it!!
>
> Pardon the sarcasm there Ken ... no offence intended.
>
> Jim

Yeah, you're right--I should get off my soapbox and be more pro-active. But it
sure is fun to pontificate while others do the dirty work!  :-P  When I started
using POV-Ray, I thought that there were armies of magical elves
behind-the-scenes, working tirelessly to make changes and corrections, just for
me!  Uh, I've grown up since then...

;-)

Seriously, though, the only hesitation I have about posting to the wiki is that,
whatever I come up with, it shouldn't be taken as *law*, but should be vetted by
people more knowledgeable than myself. I guess that *is* how it works(?) I've
never posted anything to Wikipeadia; the nuts-and-bolts of actually contributing
to a wiki is kind of mysterious to me.

But I'll make the effort, and see what happens. If I can get past this little
mental impasse--watch out!! There are LOTS of small documentation corrections
I'd like to make.

Ken


Post a reply to this message

From: Jim Holsenback
Subject: Re: rand not producing random!
Date: 12 Jan 2010 05:46:51
Message: <4b4c531b@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote in message 
news:web.4b4ba1a6cc0023fa65f302820@news.povray.org...
> But I'll make the effort, and see what happens. If I can get past this 
> little
> mental impasse--watch out!! There are LOTS of small documentation 
> corrections
> I'd like to make.

excellent ... be aware that the main documents are protected, so that's why 
the changes are done on an associated "talk" page. Since this is your first 
go round maybe you should have a look at:

http://wiki.povray.org/content/Documentation:Developers_Notes

explains where source docs came for, some don't change admonishments, and an 
example of how to do a change near the bottom of the page. I monitor "recent 
changes" (usually daily) and well give my best effort to merge changes back 
into the main docs.

Thanks for the contribution(s) ...

Jim
PS: The "preview" button at the bottom of the edit window is your friend ;-)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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