naginterfaces.library.rand.int_​binomial

naginterfaces.library.rand.int_binomial(mode, n, m, p, statecomm, comm=None)[source]

int_binomial generates a vector of pseudorandom integers from the discrete binomial distribution with parameters and .

For full information please refer to the NAG Library document for g05ta

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g05/g05taf.html

Parameters
modeint

A code for selecting the operation to be performed by the function.

Set up reference vector only.

Generate variates using reference vector set up in a prior call to int_binomial.

Set up reference vector and generate variates.

Generate variates without using the reference vector.

nint

, the number of pseudorandom numbers to be generated.

mint

, the number of trials of the distribution.

pfloat

, the probability of success of the binomial distribution.

statecommdict, RNG communication object, modified in place

RNG communication structure.

This argument must have been initialized by a prior call to init_repeat() or init_nonrepeat().

commNone or dict, communication object, optional, modified in place

Communication structure for the reference vector.

If , this argument must have been initialized by a prior call to int_binomial.

If , is not referenced and may be None.

Returns
xNone or int, ndarray, shape

The pseudorandom numbers from the specified binomial distribution.

Raises
NagValueError
(errno )

On entry, .

Constraint: , , or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

or is not the same as when [‘r’] was set up in a previous call.

Previous value of and .

Previous value of and .

(errno )

On entry, some of the elements of the array [‘r’] have been corrupted or have not been initialized.

(errno )

On entry, [‘state’] vector has been corrupted or not initialized.

Notes

int_binomial generates integers from a discrete binomial distribution, where the probability of is

where and . This represents the probability of achieving successes in trials when the probability of success at a single trial is .

The variates can be generated with or without using a search table and index. If a search table is used then it is stored with the index in a reference vector and subsequent calls to int_binomial with the same parameter values can then use this reference vector to generate further variates.

One of the initialization functions init_repeat() (for a repeatable sequence if computed sequentially) or init_nonrepeat() (for a non-repeatable sequence) must be called prior to the first call to int_binomial.

References

Kendall, M G and Stuart, A, 1969, The Advanced Theory of Statistics (Volume 1), (3rd Edition), Griffin

Knuth, D E, 1981, The Art of Computer Programming (Volume 2), (2nd Edition), Addison–Wesley