Generate a random number generator for normal deviates
This functionality does not run in MATLAB.
stats::normalRandom(m
, v
, <Seed = s
>)
stats::normalRandom(m, v)
returns a procedure
that produces normal deviates
(random numbers) with mean m and
variance v > 0.
The procedure f := stats::normalRandom(m, v)
can
be called in the form f()
. The return value of f()
is
either a floatingpoint number or a symbolic expression:
If m
and v
can be converted
to floatingpoint numbers, f()
returns a real floating
point number. Otherwise, the symbolic call stats::normalRandom(m,
v)()
is returned.
Numerical values of m
and v
are
only accepted if they are real and v is
positive.
The values X = f()
are distributed randomly
according to the cumulative distribution function of the normal distribution
with parameters m
and v
. For
any real x,
the probability that X ≤ x is
given by
.
Without the option Seed
= s
,
an initial seed is chosen internally. This initial seed is set to
a default value when MuPAD^{®} is started. Thus, each time MuPAD is
started or reinitialized with the reset
function, random generators produce
the same sequences of numbers.
Note:
In contrast to the function 
For efficiency, it is recommended to produce sequences of K random numbers via
f := stats::normalRandom(m, v): f() $k = 1..K;
rather than by
stats::normalRandom(m, v)() $k = 1..K;
The latter call produces a sequence of generators each of which is called once. Also note that
stats::normalRandom(m, v, Seed = n)() $k = 1..K;
does not produce a random sequence, because a sequence of freshly initialized generators would be created each of them producing the same number.
The function is sensitive to the environment variable DIGITS
which
determines the numerical working precision.
We generate normal deviates with mean 2 and variance :
f := stats::normalRandom(2, 3/4): f() $ k = 1..4
delete f:
With symbolic parameters, no random floatingpoint numbers can be produced:
f := stats::normalRandom(m, v): f()
When m and v evaluate
to real numbers, f
starts to produce random floating
point numbers:
m := PI: v := 1/8: f() $ k = 1..4
delete f, m, v:
We use the option Seed
= s
to
reproduce a sequence of random numbers:
f := stats::normalRandom(PI, 3, Seed = 1): f() $ k = 1..4
g := stats::normalRandom(PI, 3, Seed = 1): g() $ k = 1..4
f() = g(), f() = g()
delete f, g:

The mean: an arithmetical expression representing a real value 

The variance: an arithmetical expression representing a positive real value 

Option, specified as Initializes the random generator with the integer seed This option serves for generating generators that return predictable
sequences of pseudorandom numbers. The generator is initialized with
the seed When this option is used, the parameters 
The implemented algorithm for the computation of the normal deviates uses the BoxMueller method. For more information see: D. Knuth, Seminumerical Algorithms (1998), Vol. 2, pp. 122.