Handles all the random number logic.
Random numbers are currently generated using the mersenne twister.
Definition in file rng.c.
| double Normal |
( |
double | x | ) |
|
Calculates the Normal distribution.
Calculates N(x) where N is the normal distribution.
Approximates to a power series:
N(x) = 1 - n(x)*(b1*t + b2*t^2 + b3*t^3 + b4*t^4 + b5*t^5) + Err where t = 1 / (1 + 0.2316419*x)
Maximum absolute error is 7.5e^-8.
- Parameters
-
| x | Value to calculate the normal of. |
- Returns
- The value of the Normal.
Definition at line 201 of file rng.c.
| double NormalInverse |
( |
double | p | ) |
|
Calculates the inverse of the normal.
Lower tail quantile for standard normal distribution function.
This function returns an approximation of the inverse cumulative standard normal distribution function. I.e., given P, it returns an approximation to the X satisfying P = Pr{Z <= X} where Z is a random variable from the standard normal distribution.
The algorithm uses a minimax approximation by rational functions and the result has a relative error whose absolute value is less than 1.15e-9.
Author: Peter J. Acklam Time-stamp: 2002-06-09 18:45:44 +0200 E-mail: jackl.nosp@m.am@m.nosp@m.ath.u.nosp@m.io.n.nosp@m.o WWW URL: http://www.math.uio.no/~jacklam
C implementation adapted from Peter's Perl version.
Original algorithm from http://home.online.no/~pjacklam/notes/invnorm/ .
Definition at line 268 of file rng.c.