Generate a random number generator for Student deviates (t-deviates)
This functionality does not run in MATLAB.
stats::tRandom(a, <Seed = s>)
stats::tRandom(a) returns a procedure that produces t-deviates (random numbers) with shape parameter ('degrees of freedom') a>0.
The procedure f := stats::tRandom(a) can be called in the form f(). The return value of f() is either a floating-point number or a symbolic expression:
If a can be converted to a positive floating point number, then f() returns a real floating point number.
In all other cases, stats::tRandom(a)() is returned symbolically.
Numerical values of a are only accepted if they are real and positive.
The values X = f() are distributed randomly according to the cumulative distribution function of the t-distribution with shape parameter a. For any real x, 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 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::tRandom(a): f() $k = 1..K;
rather than by
stats::tRandom(a)() $k = 1..K;
The latter call produces a sequence of generators each of which is called once. Also note that
stats::tRandom(a, 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 t-deviates with shape parameter a = 23:
f := stats::tRandom(23): f() $ k = 1..4
With symbolic parameters, no random floating-point numbers can be produced:
f := stats::tRandom(a): f()
When the shape parameter a evaluates to a positive real number, f starts to produce random floating-point numbers:
a := sqrt(99): f() $ k = 1..4
delete f, a:
We use the option Seed = s to reproduce a sequence of random numbers:
f := stats::tRandom(PI, Seed = 1): f() $ k = 1..4
g := stats::tRandom(PI, Seed = 1): g() $ k = 1..4
f() = g(), f() = g()
delete f, g:
The shape parameter: an arithmetical expression representing a positive real value
Option, specified as Seed = s
Initializes the random generator with the integer seed s. s can also be the option CurrentTime, to make the seed depend on the current time.
This option serves for generating generators that return predictable sequences of pseudo-random numbers. The generator is initialized with the seed s which may be an arbitrary integer. Several generators with the same initial seed produce the same sequence of numbers.
When this option is used, the shape parameter a must be convertible to a positive floating-point number at the time when the random generator is generated.
The implemented algorithm for the computation of the t-deviates uses a gamma deviate X with shape parameter a/2 and a normal deviate Y to arrive at a t-deviate X/sqrt(Y/a). For more information see: D. Knuth, Seminumerical Algorithms (1998), Vol. 2, p. 135.