Generate a random number generator for beta 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::betaRandom(a
, b
, <Seed = n
>)
stats::betaRandom(a, b)
returns a procedure
that produces beta deviates (random
numbers) with shape parameters a >
0, b >
0.
The procedure f := stats::betaRandom(a, b)
can
be called in the form f()
. The return value of f()
is
either a floatingpoint number or a symbolic expression:
If a
and b
can
be converted to positive floatingpoint numbers, then f()
returns
a random floatingpoint number between 0.0
and 1.0
.
In all other cases, f() return
the symbolic call stats::betaRandom(a, b)()
.
Numerical values of a
and b
are
only accepted if they are positive.
The values X = f()
are distributed randomly
according to the beta distribution with parameters a
and b
.
For any 0 ≤ x ≤
1, 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 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::betaRandom(a, b): f() $ k = 1..K;
stats::betaRandom(a, b)() $ k = 1..K;
stats::betaRandom(a, b, Seed = n)() $ k = 1..K;
The function is sensitive to the environment variable DIGITS
which
determines the numerical working precision.
We generate beta deviates with parameters a = 2 and :
f := stats::betaRandom(2, 3/4): f() $ k = 1..4
delete f:
With symbolic parameters, no random floatingpoint numbers can be produced:
f := stats::betaRandom(a, b): f()
When a
and b
evaluate
to positive real numbers, the generator starts to produce random numbers:
a := 1: b := 2: f() $ k = 1..4
delete f, a, b:
We use the option Seed = s
to reproduce a
sequence of random numbers:
f := stats::betaRandom(1, 3, Seed = 1): f() $ k = 1..4
g := stats::betaRandom(1, 3, Seed = 1): g() $ k = 1..4
f() = g(), f() = g()
delete f, g:

The shape parameters of the beta distribution: arithmetical expressions representing positive real values. 

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 shape parameters 
The implemented algorithm for the computation of the beta deviates
uses gamma deviates x
, y
to
produce a beta deviate x/(x + y)
. For more information
see: D. Knuth, Seminumerical Algorithms (1998), Vol. 2, p. 134.