randomNormal¶
Generates pseudorandom numbers from a standard normal distribution using an inverse CDF method.
Synopsis¶
randomNormal (nRandom)
Required Arguments¶
- int
nRandom
(Input) - Number of random numbers to generate.
Return Value¶
A vector of length nRandom
containing the random standard normal
deviates.
Description¶
Function randomNormal
generates pseudorandom numbers from a standard
normal (Gaussian) distribution using an inverse CDF technique. In this
method, a uniform (0, 1) random deviate is generated. Then, the inverse of
the normal distribution function is evaluated at that point, using the
function normalInverseCdf
(See Chapter 11 of the PyIMSL Stat Numerical
Library user guide.)
Deviates from the normal distribution with mean mean
and standard
deviation std_dev
can be obtained by scaling the output from
randomNormal
.
Example¶
In this example, randomNormal
is used to generate five pseudorandom
deviates from a standard normal distribution.
from __future__ import print_function
from numpy import *
from pyimsl.math.randomNormal import randomNormal
from pyimsl.math.randomSeedSet import randomSeedSet
randomSeedSet(123457)
r = randomNormal(5)
print("Standard normal random deviates: %8.4f%8.4f%8.4f%8.4f%8.4f"
% (r[0], r[1], r[2], r[3], r[4]))
Output¶
Standard normal random deviates: 1.8279 -0.6412 0.7266 0.1747 1.0145
Remark¶
The function randomSeedSet can be used to initialize the seed of the random number generator. The function randomOption can be used to select the form of the generator.