POV-Ray : Newsgroups : povray.general : QUESTION: Random Seed deriving from Time? Server Time
29 Mar 2024 10:01:25 EDT (-0400)
  QUESTION: Random Seed deriving from Time? (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: clipka
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 21:22:31
Message: <5a8a34e7$1@news.povray.org>
Am 18.02.2018 um 22:24 schrieb Sven Littkowski:
> I am trying this
> #declare MyRandomer   = seed(CURRENTTIMESTAMP);
> 
> and this
> #declare MyRandomer   = seed(msg:CURRENTTIMESTAMP);
> 
> but only errors. please assist. Thanks!

Out of pure curiosity: How did you come up with that particular syntax?


The keyword you're looking for is `now`, which returns the time elapsed
since 2000-01-01, 00:00:00 GMT, in (fractional) days.

Note that since `seed()` converts its parameter to an integer, you need
to scale the result of `now` to whatever granularity you need for the
seed. For instance, for the seed to change every hour, use:

    #declare MyRandomer = seed(now * 24);

Note that the value of `now` changes even during parsing.

Also note that the resolution of the underlying timer may vary between
systems, and may be as poor as a second per tick.


Finally, due to the nature of the inbuilt random number generator, the
first few values pulled from the generator may remain somewhat similar
between consecutive seeds, so you may want to choose your granularity
somewhat higher than absolutely necessary, or always discard the first
few random numbers (maybe a dozen or so) pulled from the generator.


Post a reply to this message

From: Sven Littkowski
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 21:45:58
Message: <5a8a3a66$1@news.povray.org>
On 18.02.2018 21:22, clipka wrote:
> Am 18.02.2018 um 22:24 schrieb Sven Littkowski:
>> I am trying this
>> #declare MyRandomer   = seed(CURRENTTIMESTAMP);
>>
>> and this
>> #declare MyRandomer   = seed(msg:CURRENTTIMESTAMP);
>>
>> but only errors. please assist. Thanks!
> 
> Out of pure curiosity: How did you come up with that particular syntax?
> 
> 
> The keyword you're looking for is `now`, which returns the time elapsed
> since 2000-01-01, 00:00:00 GMT, in (fractional) days.
> 
> Note that since `seed()` converts its parameter to an integer, you need
> to scale the result of `now` to whatever granularity you need for the
> seed. For instance, for the seed to change every hour, use:
> 
>     #declare MyRandomer = seed(now * 24);
> 
> Note that the value of `now` changes even during parsing.
> 
> Also note that the resolution of the underlying timer may vary between
> systems, and may be as poor as a second per tick.
> 
> 
> Finally, due to the nature of the inbuilt random number generator, the
> first few values pulled from the generator may remain somewhat similar
> between consecutive seeds, so you may want to choose your granularity
> somewhat higher than absolutely necessary, or always discard the first
> few random numbers (maybe a dozen or so) pulled from the generator.
> 
Hi.

The POV-Ray help file did not mention "now", and so I started to search
online but without knowing what exact keywords to look for. Eventually,
I came accross a web page thatwas about POV-Ray and also featured
"CURRENTTIMESTAMP". I believed it was more about programming then
anything I could use in a scene, but i wanted to give a try, and that's
how I got these variations you saw.

I use "now" but the renders still look the same, like the seed would
remain the same. I make the renders in intervals of less than a minute.
Thus, a seed that changes each second would be nice.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: dick balaska
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 21:57:36
Message: <5a8a3d20$1@news.povray.org>
On 02/18/2018 09:45 PM, Sven Littkowski wrote:

> 
> I use "now" but the renders still look the same, like the seed would
> remain the same. I make the renders in intervals of less than a minute.
> Thus, a seed that changes each second would be nice.

Instead of changing the seed, how about throw away the first (now-start) 
random numbers? or (now-start)*2

-- 
dik
Rendered 920576 of 921600 pixels (99%)


Post a reply to this message

From: clipka
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 22:03:36
Message: <5a8a3e88$1@news.povray.org>
Am 19.02.2018 um 03:45 schrieb Sven Littkowski:

> The POV-Ray help file did not mention "now", and so I started to search
> online but without knowing what exact keywords to look for. Eventually,
> I came accross a web page thatwas about POV-Ray and also featured
> "CURRENTTIMESTAMP". I believed it was more about programming then
> anything I could use in a scene, but i wanted to give a try, and that's
> how I got these variations you saw.

Strange. Maybe it was something the author passed into POV-Ray from an
external script, via the `Declare` INI-file setting.

> I use "now" but the renders still look the same, like the seed would
> remain the same. I make the renders in intervals of less than a minute.
> Thus, a seed that changes each second would be nice.

Using just `seed(now)`, the random sequence changes only once each day.
For the sequence to change every second, use `seed(now * 24*60*60)` instead.


Post a reply to this message

From: clipka
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 22:26:02
Message: <5a8a43ca@news.povray.org>
Am 19.02.2018 um 03:57 schrieb dick balaska:
> On 02/18/2018 09:45 PM, Sven Littkowski wrote:
> 
>>
>> I use "now" but the renders still look the same, like the seed would
>> remain the same. I make the renders in intervals of less than a minute.
>> Thus, a seed that changes each second would be nice.
> 
> Instead of changing the seed, how about throw away the first (now-start)
> random numbers? or (now-start)*2

I wouldn't recommend that.

First of all, this would increase parse time on a daily basis.

Second, in any scenario where many random numbers are needed and their
order doesn't matter (such as when randomly placing many objects), this
would be virtually useless as it would only ditch the first few random
numbers and replace them with what would then be the last few random
numbers.

Third, two sequences even from neighboring seeds should diverge
sufficiently after a few couple of values (maybe a dozen), so throwing
away a small fixed count of random numbers should suffice.

That is, unless the seeds only differ in the fractional part (e.g. 471.1
vs. 471.2), in which case the sequences will be completely identical.
But the same goes for the approach you're presenting.


Post a reply to this message

From: Sven Littkowski
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 19 Feb 2018 09:18:59
Message: <5a8adcd3$1@news.povray.org>
Thanks, that is what was needed!

I think, the SEED chapter of the POV-Ray help file really need to
mention "now" and "now * 24*60*60", as many users might be in need of
irregularly random renders. "Now" is not even mentioned at all there,
now does the key "F1" open any content help for "now".

In fact, even with many existing keywords in the help file, only this
happens when clicking them: the HELP opens a new page, but that is just
the begin of the documentation, not the part dealing with that
particular keyword.

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Alain
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 19 Feb 2018 17:00:36
Message: <5a8b4904$1@news.povray.org>
Le 18-02-18 à 21:45, Sven Littkowski a écrit :
> On 18.02.2018 21:22, clipka wrote:
>> Am 18.02.2018 um 22:24 schrieb Sven Littkowski:
>>> I am trying this
>>> #declare MyRandomer   = seed(CURRENTTIMESTAMP);
>>>
>>> and this
>>> #declare MyRandomer   = seed(msg:CURRENTTIMESTAMP);
>>>
>>> but only errors. please assist. Thanks!
>>
>> Out of pure curiosity: How did you come up with that particular syntax?
>>
>>
>> The keyword you're looking for is `now`, which returns the time elapsed
>> since 2000-01-01, 00:00:00 GMT, in (fractional) days.
>>
>> Note that since `seed()` converts its parameter to an integer, you need
>> to scale the result of `now` to whatever granularity you need for the
>> seed. For instance, for the seed to change every hour, use:
>>
>>      #declare MyRandomer = seed(now * 24);
>>
>> Note that the value of `now` changes even during parsing.
>>
>> Also note that the resolution of the underlying timer may vary between
>> systems, and may be as poor as a second per tick.
>>
>>
>> Finally, due to the nature of the inbuilt random number generator, the
>> first few values pulled from the generator may remain somewhat similar
>> between consecutive seeds, so you may want to choose your granularity
>> somewhat higher than absolutely necessary, or always discard the first
>> few random numbers (maybe a dozen or so) pulled from the generator.
>>
> Hi.
> 
> The POV-Ray help file did not mention "now", and so I started to search
> online but without knowing what exact keywords to look for. Eventually,
> I came accross a web page thatwas about POV-Ray and also featured
> "CURRENTTIMESTAMP". I believed it was more about programming then
> anything I could use in a scene, but i wanted to give a try, and that's
> how I got these variations you saw.
> 
> I use "now" but the renders still look the same, like the seed would
> remain the same. I make the renders in intervals of less than a minute.
> Thus, a seed that changes each second would be nice.
> 
> ---
> Diese E-Mail wurde von AVG auf Viren geprüft.
> http://www.avg.com
> 

Try something like :
#declare SecondPerDay = 60*60*24; //or 86400
#declare MyRandomer = seed(now * SecondPerDay);

You can artificially make your seconds smaller by increasing the value 
to your liking :
#declare Over = 1.5;
#declare SecondPerDay = 60*60*24*Over;

Next, use some dumy uses to skip a few initial values from the stream.


Post a reply to this message

From: Alain
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 19 Feb 2018 17:05:01
Message: <5a8b4a0d$1@news.povray.org>
Le 18-02-19 à 09:18, Sven Littkowski a écrit :
> Thanks, that is what was needed!
> 
> I think, the SEED chapter of the POV-Ray help file really need to
> mention "now" and "now * 24*60*60", as many users might be in need of
> irregularly random renders. "Now" is not even mentioned at all there,
> now does the key "F1" open any content help for "now".
> 
> In fact, even with many existing keywords in the help file, only this
> happens when clicking them: the HELP opens a new page, but that is just
> the begin of the documentation, not the part dealing with that
> particular keyword.
> 
> ---
> Diese E-Mail wurde von AVG auf Viren geprüft.
> http://www.avg.com
> 

The included help was not completely updated since version 3.6.0, and 
now did not exist back then.
You may have beter results using the wiki based help.


Post a reply to this message

From: Sven Littkowski
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 20 Feb 2018 00:30:57
Message: <5a8bb291@news.povray.org>
Thanks. For me it is fine, to use seconds as smallest unit. Nonetheless,
I am learning something new with your answer.

But I want to say, that I appreciate a lot the good will and great
spirit in our group!

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

From: Sven Littkowski
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 20 Feb 2018 00:31:37
Message: <5a8bb2b9$1@news.povray.org>
Hopefully, there's a way to convert the Wiki into a functioning Help
file.   ;-)

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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