Generate a random number generator for Erlang deviates
This functionality does not run in MATLAB.
stats::erlangRandom(a, b, <Seed = n>)
stats::erlangRandom(a, b) returns a procedure that produces Erlang deviates (random numbers) with shape parameter a > 0 and scale parameter b > 0.
The procedure f := stats::erlangRandom(a, b) can be called in the form f(). The return value of f() is either a floating-point number or a symbolic expression:
If a and b can be converted to positive floating-point numbers, then f() returns a nonnegative floating-point number.
In all other cases, stats::erlangRandom(a, b)() is returned symbolically.
Numerical values of a and b are only accepted if they are real and positive.
The values X = f() are distributed randomly according to the cumulative distribution function of the Erlang distribution with parameters a and b. For any 0 ≤ x, the probability that X ≤ x is given by
Without the option Seed = n, 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 re-initialized with the reset function, random generators produce the same sequences of numbers.
For efficiency, it is recommended to produce sequences of K random numbers via
f := stats::erlangRandom(a, b): f() $k = 1..K;
rather than by
stats::erlangRandom(a, b)() $k = 1..K;
The latter call produces a sequence of generators each of which is called once. Also note that
stats::erlangRandom(a, b, 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.
Note that stats::erlangRandom(a, b) = stats::gammaRandom(a, 1/b).
The function is sensitive to the environment variable DIGITS which determines the numerical working precision.
We generate Erlang deviates with parameters a = 2 and :
f := stats::erlangRandom(2, 3/4): f() $ k = 1..4
With symbolic parameters, no random floating-point numbers can be produced:
f := stats::erlangRandom(a, b): f()
When positive real numbers are assigned to a and b, the function f starts to produce random floating point numbers:
a := PI: b := 1/8: f() $ k = 1..4
delete f, a, b:
We use the option Seed = n to reproduce a sequence of random numbers:
f := stats::erlangRandom(PI, 3, Seed = 1): f() $ k = 1..4
g := stats::erlangRandom(PI, 3, Seed = 1): g() $ k = 1..4
f() = g(), f() = g()
delete f, g:
The shape parameter: an arithmetical expression representing a positive real value
The scale parameter: an arithmetical expression representing a positive real value
Option, specified as Seed = n
Initializes the random generator with the integer seed n. n can also be the option CurrentTime, to make the seed depend on the current time.
This option serves for generating generators that return predictable sequences of pseudo-random numbers. The generator is initialized with the seed n which may be an arbitrary integer. Several generators with the same initial seed produce the same sequence of numbers.
When this option is used, the parameters a and b must be convertible to positive floating-point numbers at the time when the random generator is generated.