POV-Ray : Newsgroups : povray.advanced-users : Random number generator needed ! Server Time
29 Jul 2024 22:24:37 EDT (-0400)
  Random number generator needed ! (Message 11 to 20 of 41)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Christoph Hormann
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 17:42:37
Message: <3A92F2DD.CCE12EC3@gmx.de>
Rune wrote:
> 
> That might work, but is there any of the "random" patterns that have
> completely equally distributed values?
> 

Not sure what you mean, you should not use noise_pigment, because it does
not give reproducible results, any other 'noisy' pattern should work as
long as the minimum distance between two evaluated points is larger than
the structures in the pattern, otherwise two neighboring points give
similar results.  

Christoph

-- 
Christoph Hormann <chr### [at] gmxde>
IsoWood include, radiosity tutorial, TransSkin and other 
things on: http://www.schunter.etc.tu-bs.de/~chris/


Post a reply to this message

From: Chris Huff
Subject: Re: Random number generator needed !
Date: 20 Feb 2001 22:05:15
Message: <chrishuff-9D830E.22043620022001@news.povray.org>
In article <3a92f00e@news.povray.org>, "Rune" <run### [at] inamecom> 
wrote:

> There are many reasons. For example I want my particle system to be 
> frame-independent, so that the even the randomness of the particles 
> is the same independent on the frame-rate used. I also need it for 
> the cyclic animation feature where the whole calculation process is 
> basically run through several times, and where the random numbers 
> must be the same each time.

If I understand this correctly, you may want to try separating your 
render frames from your calculation frames...do a fixed number of 
iterations for a specific time period (for example, always compute 500 
iterations by the time clock reaches 1), and you will get the same 
result. Of course, it won't work very well if you use more frames than 
iterations, but you might be able to work out an interpolation method to 
save computation time and get reasonably good results.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Geoff Wedig
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 07:44:07
Message: <3a93b817@news.povray.org>
Rune <run### [at] inamecom> wrote:

> "Lutz-Peter Hooge" wrote:
>> I think an array initialized with random numbers could be
>> used for this. Of course it will need to be very large, or
>> the numbers will repeat much more often than in a normal
>> random numer stream.

> At first I thought the array needed would be too large, but wouldn't it work
> to make a relative small array, and then use averages of different numbers
> from the array?

> If 3 numbers from the array were averaged the amount of different numbers
> would be array_length^3 and if 8 numbers were averaged it would be ^8 !

> Maybe this is the solution?

Those wouldn't be equally distributed though.  The mean of three uniformly
distributed numbers is not uniformly distributed.

Geoff


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 08:26:16
Message: <3a93c1f8@news.povray.org>
Rune wrote in message <3a92cca8@news.povray.org>...
> I need a macro that outputs a random number between 0 and 1 when called. It
> should have two integers as input. The reason I can't just use rand() and
> seed() is that I need it to always output the same random number when the
> same input numbers are used.
>
> I need a macro like this: Rand (Int1, Int2)
>
> I don't know anything about random number generators myself, so some help
> would be much appreciated.


perhaps this will help you:

#macro Rand(I1,I2)
  rand(seed(val(concat(str(I1,0,0),str(I2,0,0)))))
#end

ABX


Post a reply to this message

From: Warp
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 09:11:41
Message: <3a93cc9d@news.povray.org>
Wlodzimierz ABX Skiba <abx### [at] abxartpl> wrote:
:   rand(seed(val(concat(str(I1,0,0),str(I2,0,0)))))

  Isn't this effectively the same as:

  rand(seed(I1*I2))

?

  (Not identically the same result, but effectively the same idea.)

-- 
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: Wlodzimierz ABX Skiba
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 09:22:03
Message: <3a93cf0b@news.povray.org>
Warp wrote in message <3a93cc9d@news.povray.org>...
> Wlodzimierz ABX Skiba <abx### [at] abxartpl> wrote:
> :   rand(seed(val(concat(str(I1,0,0),str(I2,0,0)))))
> Isn't this effectively the same as:
> rand(seed(I1*I2))
> (Not identically the same result, but effectively the same idea.)


multiplication has symetry
concatenation hasn't

ABX


Post a reply to this message

From: Warp
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 11:16:52
Message: <3a93e9f3@news.povray.org>
Wlodzimierz ABX Skiba <abx### [at] abxartpl> wrote:
: multiplication has symetry
: concatenation hasn't

  Your solution just multiplies I1 with the smallest multiple of 10 that
is larger or equal to I2 and then adds I2 to the result.

  This is effectively the same as I1*I2+I2, the only difference being that
instead of multiplying with a the smallest multiple of 10 which is larger
or equal to I2, we are multplying with the smallest number which is larger
or equal to I2, which is, of course, I2 itself.
  Now, I1*I2+I2 = (I1+1)*I2, and by all practical means this probably will
not give a too different result than just I1*I2.

  That's why I think that I1*I2 will probably give an equally good result
with less overhead.

-- 
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: Rune
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 11:46:19
Message: <3a93f0db@news.povray.org>
"Wlodzimierz ABX Skiba" wrote:
> perhaps this will help you:
>
> #macro Rand(I1,I2)
>   rand(seed(val(concat(str(I1,0,0),str(I2,0,0)))))
> #end

Unfortunately not. It's not at all random...

Basically it will never be of any use to use rand( seed( VAL ) ) no matter
what "VAL" is, because it won't add any randomness at all.

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

From: Rune
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 11:46:20
Message: <3a93f0dc@news.povray.org>
"Geoff Wedig" wrote:
> Rune <run### [at] inamecom> wrote:
>
> > "Lutz-Peter Hooge" wrote:
> >> I think an array initialized with random numbers could be
> >> used for this. Of course it will need to be very large, or
> >> the numbers will repeat much more often than in a normal
> >> random numer stream.
>
> > At first I thought the array needed would be too large, but wouldn't it
work
> > to make a relative small array, and then use averages of different
numbers
> > from the array?
>
> > If 3 numbers from the array were averaged the amount of different
numbers
> > would be array_length^3 and if 8 numbers were averaged it would be ^8 !
>
> > Maybe this is the solution?
>
> Those wouldn't be equally distributed though.  The mean of three uniformly
> distributed numbers is not uniformly distributed.
>
> Geoff


Post a reply to this message

From: Rune
Subject: Re: Random number generator needed !
Date: 21 Feb 2001 11:46:21
Message: <3a93f0dd$1@news.povray.org>
"Geoff Wedig" wrote:
> > wouldn't it work to make a relative small array, and then
> > use averages of different numbers from the array?
>
> Those wouldn't be equally distributed though.  The mean of
> three uniformly distributed numbers is not uniformly
> distributed.

Yes, I realised that...

Maybe instead of averaging I can just add together and then use mod() on the
result. It may cause a kind of repeats in the pattern, but it should be
possible to reduce it to a minimum.

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated January 28)
/ Also visit http://www.povrayusers.org


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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