Generate a random number generator for exponential deviates
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
Seed = n>)
stats::exponentialRandom(a, b) returns a
procedure that produces exponential deviates
(random numbers) with real location parameter a and
scale parameter b > 0.
f := stats::exponentialRandom(a, b) can
be called in the form
f(). The return value of
either a floating-point number or a symbolic expression:
a can be converted to a real floating
point number and
b to a positive floating-point
f() returns nonnegative floating-point
In all other cases,
stats::exponentialRandom(a, b)() is
Numerical values of
only accepted if they are real and
b is positive.
X = f() are distributed randomly
according to the cumulative distribution function of the exponential
distribution with parameters
For real x ≥ a,
the probability that X ≤ x is
Without the option
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::exponentialRandom(a, b): f() $k = 1..K;
rather than by
stats::exponentialRandom(a, b)() $k = 1..K;
The latter call produces a sequence of generators each of which is called once. Also note that
stats::exponentialRandom(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.
The function is sensitive to the environment variable
determines the numerical working precision.
We generate exponential deviates with parameters a = 2 and :
f := stats::exponentialRandom(2, 3/4): f() $ k = 1..4
With symbolic parameters, no random floating-point numbers can be produced:
f := stats::exponentialRandom(a, b): f()
When a and b evaluate
to suitable real numbers,
f starts to produce random
a := PI: b := 1/8: f() $ k = 1..4
delete f, a, b:
We use the option
reproduce a sequence of random numbers:
f := stats::exponentialRandom(PI, 1/2, Seed = 1): f() $ k = 1..4
g := stats::exponentialRandom(PI, 1/2, Seed = 1): g() $ k = 1..4
f() = g(), f() = g()
delete f, g:
The location parameter: an arithmetical expression representing a real value
The scale parameter: 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 pseudo-random numbers. The generator is initialized with
When this option is used, the parameters
The implemented algorithm for the computation of the exponential deviates uses the quantile function of the exponential distribution applied to uniformly distributed random numbers between 0 and 1.