(update: the probability density function of a random number generator is the derivative of the generating function, so in this case a cosine density shape is therefore being produced.)use Math::Trig; # to get PI my $sinerand = sin( rand() * PI );
A simple integration is also needed for the triangular distribution: Its probability density function has a smooth gradient so the generator satisfies the equation dy/dx = gradient. So integrating that straight line function, gives the generating function: 1 - (rand() ** (1+gradient))) would give a random number with a triangular probability density function coming out.
The reason the normal distribution is an exception deserving a special method is that its cumulative distribution function isn't analytic but can only be expressed as an integral equation. (Update: or as a Taylor Series.)
You would need to achieve an impossible integration (in closed form) to compute the generating function that can produce a normal probability density function as its output. In practice some kind of approximation has to be used (Update: usually by taking the first few terms of the infinite Taylor series - although I have to say the module either doesn't or doesn't obviously do that!)
^M Free your mind!
In reply to Re: geometric random distributions
by Moron
in thread geometric random distributions
by kingkongrevenge
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |