naginterfaces.library.rand.int_hypergeom(mode, n, ns, np, m, statecomm, comm=None)[source]

int_hypergeom generates a vector of pseudorandom integers from the discrete hypergeometric distribution of the number of specified items in a sample of size , taken from a population of size with specified items in it.

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


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_hypergeom.

Set up reference vector and generate variates.

Generate variates without using the reference vector.


, the number of pseudorandom numbers to be generated.


, the sample size of the hypergeometric distribution.


, the population size of the hypergeometric distribution.


, the number of specified items of the hypergeometric 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_hypergeom.

If , is not referenced and may be None.

xNone or int, ndarray, shape

The pseudorandom numbers from the specified hypergeometric distribution.

(errno )

On entry, .

Constraint: , , or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

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

(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.


int_hypergeom generates integers from a discrete hypergeometric distribution, where the probability of 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_hypergeom with the same parameter values can then use this reference vector to generate further variates. The reference array is generated by a recurrence relation if , otherwise Stirling’s approximation is used.

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_hypergeom.


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