Advertisement

Randm Number Generation

Started by July 13, 2002 10:29 AM
12 comments, last by oveja-carnivora 22 years, 7 months ago
Grr... my reply just got eaten by the net-demon!

there are two ways to use the formula:

1) invert it and solve for x. There''s a sqrt in the answer. Sample uniformly from [0,1] and sub in for p(x) in the sqrt term. Check for non-negative sqrt argument. If positive, you get two values for x. Sample from [0,1] again split on 0.5. Take one value of x for <0.5, other value for higher or equal to.

2) Compute cumulative probability distibution of the above density function. This gives a mapping from [-infty,+infty] onto [0,1] that has Gaussian statistics. Implement it as a lookup table. Sample uniformly from [0,1] and return the value of x that matches it.

Sorry for the brevity... I really didn''t want to type out my long response again!

Cheers,

Timkin

BTW: The Box-Muller method if fairly straightforward. As for the code I mentioned, go here.
quote:
Original post by Timkin
Grr... my reply just got eaten by the net-demon!
When that happens to me, I just press "refresh"...
Advertisement
quote:

It results in solid, rectangular edges on the stream of particles because the vectors of all of the particles are evenly distributed to the defined limit


You''re not stuck to a box shaped origin for your particles
You may have :
a sphere (radius, rotate x, rotate y)
a disc (radius, rotate y)
a square (x, y)
etc...

----
David Sporn AKA Sporniket
quote:
Original post by Beer Hunter
When that happens to me, I just press "refresh"...


Not possible when the window goes with it as well!

Tikin

[edited by - Timkin on July 16, 2002 7:51:45 PM]

This topic is closed to new replies.

Advertisement