stats
::geometricRandom
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.
stats::geometricRandom(p
, <Seed = s
>)
stats::geometricRandom(p)
returns a procedure
that produces geometric deviates
(random numbers) with `probability parameter' p
.
The procedure f:=stats::geometricRandom(p)
can
be called in the form f()
. The return value of f()
is
a positive integer if p
is a real number satisfying 0
≤ p ≤ 1.
Otherwise, stats::geometricRandom(p)()
is
returned symbolically.
Numerical values for p
are only accepted
if they satisfy 0 ≤ p ≤
1.
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 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.
With this option, the parameter p
must evaluate
to a numerical value at the time, when the generator is created.
In contrast to the function random
, the generators produced by stats::geometricRandom
do
not react to the environment variable SEED
.
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 DIGITS
which
determines the numerical working precision.
We generate geometric deviates with :
f := stats::geometricRandom(1/3): f() $ k = 1..10
delete f:
With symbolic parameters, no random floatingpoint 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 Seed
= s
to
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 pseudorandom numbers. The generator is initialized with
the seed When this option is used, the parameter 