Generate a random number generator for geometric 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 = s>)
stats::geometricRandom(p) returns a procedure
that produces geometric deviates
(random numbers) with `probability parameter'
be called in the form
f(). The return value of
a positive integer if
p is a real number satisfying 0
≤ p ≤ 1.
Numerical values for
p are only accepted
if they satisfy 0 ≤ p ≤
The values X = f() are distributed randomly according to the discrete distribution function of the geometric distribution with parameter p, i.e., for 1 ≤ x, the probability of X ≤ x is given by .
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.
With this option, the parameter
For efficiency, it is recommended to produce sequences of K random numbers via
f := stats::geometricRandom(p): f() $k = 1..K;
rather than by
stats::geometricRandom(p)() $k = 1..K;
The latter call produces a sequence of generators each of which is called once. Also note that
stats::geometricRandom(p, Seed = s)() $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 geometric deviates with :
f := stats::geometricRandom(1/3): f() $ k = 1..10
With symbolic parameters, no random floating-point numbers can be produced:
f := stats::geometricRandom(p): f()
When p evaluates to a real number between 0 and 1, the generator starts to produce random numbers:
p := 1/sqrt(70): f(), f(), f()
delete f, p:
We use the option
reproduce a sequence of random numbers:
f := stats::geometricRandom(1/10, Seed = 1): f() $ k = 1..10
g := stats::geometricRandom(1/10, Seed = 1): g() $ k = 1..10
f() = g(), f() = g()
delete f, g:
The "probability parameter": an arithmetical expression representing a real number 0 ≤ p ≤ 1.
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 parameter