Generate a random number generator for uniformly continous 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::uniformRandom(a
, b
, <Seed = s
>)
stats::uniformRandom(a, b)
returns a procedure
that produces uniformly continous deviates
(random numbers) on the interval
.
The procedure f := stats::uniformRandom(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 floatingpoint numbers, then f()
returns a floating
point number between a and b.
In all other cases, stats::uniformRandom(a, b)()
is
returned symbolically.
Numerical values of a
and b
are
only accepted if they are real and a ≤ b.
The values X = f()
are distributed randomly
according to the cumulative distribution function of the uniform distribution
on the interval
.
For any a ≤ x ≤ b,
the probability that 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.
Note:
In contrast to the function 
For efficiency, it is recommended to produce sequences of K random
numbers via f := stats::uniformRandom(a, b): f() $ k = 1..K
rather
than by stats::uniformRandom(a, b)() $ k = 1..K
The
latter call produces a sequence of generators each of which is called
once. Also note that
stats::uniformRandom(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 DIGITS
which
determines the numerical working precision.
We generate uniform deviates on the interval :
f := stats::uniformRandom(2, 7): f() $ k = 1..4
delete f:
With symbolic parameters, no random floatingpoint numbers can be produced:
f := stats::uniformRandom(a, b): f()
When a and b evaluate
to real numbers, f
starts to produce random floating
point numbers:
a := PI: b := 10: f() $ k = 1..4
delete f, a, b:
We use the option Seed
= s
to
reproduce a sequence of random numbers:
f := stats::uniformRandom(0, 10, Seed = 10^3): f() $ k = 1..4
g := stats::uniformRandom(0, 10, Seed = 10^3): g() $ k = 1..4
f() = g(), f() = g()
delete f, g:

arithmetical expressions representing real values; a ≤ b is assumed. 

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 parameters 
Uniform deviates on the interval
are
produced via a + (b  a)*
frandom()
.