POV-Ray : Newsgroups : povray.general : QUESTION: Random Seed deriving from Time? Server Time
23 Dec 2024 15:19:23 EST (-0500)
  QUESTION: Random Seed deriving from Time? (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Sven Littkowski
Subject: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 16:03:28
Message: <5a89ea20$1@news.povray.org>
Hi,

in order to get a permanently changing random seed, is there a way to
use a TIME VALUE (time stamp) instead of a fixed seed value?

---
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: 18 Feb 2018 16:24:52
Message: <5a89ef24$1@news.povray.org>
I am trying this
#declare MyRandomer   = seed(CURRENTTIMESTAMP);

and this
#declare MyRandomer   = seed(msg:CURRENTTIMESTAMP);

but only errors. please assist. Thanks!

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


Post a reply to this message

From: Bald Eagle
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 16:55:01
Message: <web.5a89f51b54bead6e5cafe28e0@news.povray.org>
use now or datetime

http://news.povray.org/povray.general/thread/%3C546e4c1a%241%40news.povray.org%3E/


Post a reply to this message

From: Sven Littkowski
Subject: Re: QUESTION: Random Seed deriving from Time?
Date: 18 Feb 2018 19:39:39
Message: <5a8a1ccb$1@news.povray.org>
Cool! Yes, now it works! Thanks a lot!

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


Post a reply to this message

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

Goto Latest 10 Messages Next 4 Messages >>>

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