Documentation Center

  • Trial Software
  • Product Updates

stats::geometricRandom

Generate a random number generator for geometric deviates

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

stats::geometricRandom(p, <Seed = s>)

Description

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 Xx 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 parameter p must evaluate to a numerical value at the time, when the generator is created.

    Note:   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.

Environment Interactions

The function is sensitive to the environment variable DIGITS which determines the numerical working precision.

Examples

Example 1

We generate geometric deviates with :

f := stats::geometricRandom(1/3): f() $ k = 1..10

delete f:

Example 2

With symbolic parameters, no random floating-point 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:

Example 3

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:

Parameters

p

The "probability parameter": an arithmetical expression representing a real number 0 ≤ p ≤ 1.

Options

Seed

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 parameter p must be convertible to a floating-point number between 0.0 and 1.0 at the time when the random generator is generated.

Return Values

procedure.

See Also

MuPAD Functions

Was this topic helpful?