naginterfaces.library.rand.permute

naginterfaces.library.rand.permute(indx, statecomm)[source]

permute performs a pseudorandom permutation of a vector of integers.

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

https://www.nag.com/numeric/nl/nagdoc_29.3/flhtml/g05/g05ncf.html

Parameters
indxint, array-like, shape

The integer values to be permuted.

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

Returns
indxint, ndarray, shape

The permuted integer values.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

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

Notes

permute permutes the elements of an integer array without inspecting their values. Each of the possible permutations of the values may be regarded as being equally probable.

Even for modest values of it is theoretically impossible that all permutations may occur, as is likely to exceed the cycle length of any of the base generators. For practical purposes this is irrelevant, as the time necessary to generate all possible permutations is many millenia.

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

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