Ask Your Question

Revision history [back]

Syntax

stats::binomialRandom(n, p, <seed =="" s="">) Description

stats::binomialRandom(n, p) returns a procedure that produces binomial-deviates (random numbers) with trial parameter n and probability parameter p.

The procedure f := stats::binomialRandom(n, p) can be called in the form f(). The return value of f() is an integer between 0 and n or a symbolic expression:

If n is a positive integer and p is a real value satisfying 0 ≤ p ≤ 1, then f() returns an integer between 0 and n. If p = 0 or p = 0.0, then f() returns 0 for any value of n. If p = 1 or p = 1.0, then f() returns n for any value of n. In all other cases, f() return the symbolic call stats::binomialRandom(n, p)(). Numerical values for n are only accepted if they are positive integers.

Numerical values for p are only accepted if they satisfy 0 ≤ p ≤ 1.

The values X = f() are distributed randomly according to the binomial distribution with trial parameter n and probability parameter p. For any , 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 re-initialized with the reset function, random generators produce the same sequences of numbers.

Note: With this option, the parameters n and p must evaluate to suitable numerical values at the time, when the generator is created. Note: In contrast to the function random, the generators produced by stats::binomialRandom do not react to the environment variable SEED. For efficiency, it is recommended to produce sequences of K random numbers via

f := stats::binomialRandom(n, p): f() $k = 1..K; rather than by stats::binomialRandom(n, p)() $k = 1..K; The latter call produces a sequence of generators each of which is called once. Also note that stats::binomialRandom(n, 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.