pyhctsa.robust.bf_random

pyhctsa.robust.bf_random(n, seed=0, kind='uniform')

Portable pseudo-random numbers: a stream fixed by the seed alone (hctsa BF_Random).

L’Ecuyer’s combined multiple recursive generator MRG32k3a (L’Ecuyer 1999, doi:10.1287/opre.47.1.159), in integer arithmetic. It leaves NumPy’s global random state untouched. The uniform stream is exactly that of hctsa’s BF_Random (integer arithmetic); normal draws are Box-Muller transforms of it, accurate to the rounding of log, cos and sin (about 1e-16).

Parameters:
n : int

The number of values to return.

seed : int or sequence of 6 ints, optional

A scalar seed (integer in [0, 4e9)) sets all six state words to 12345 + seed and discards the first 8 draws, so that streams from neighboring seeds are unrelated (default 0). A vector of six state words [s10 s11 s12 s20 s21 s22] starts the raw generator with no draws discarded; the state [12345]*6 reproduces L’Ecuyer’s reference implementation.

kind : {'uniform', 'normal', 'perm'}, optional

'uniform': n numbers in the open interval (0,1) (default). 'normal': n standard normal numbers by Box-Muller: the uniforms (u1, u2) = (2k-1, 2k) give sqrt(-2 log u1) cos(2 pi u2) and sqrt(-2 log u1) sin(2 pi u2) as values 2k-1 and 2k. 'perm': a random permutation of 0..n-1 (0-based indices): the stable argsort of n uniform numbers. (hctsa’s BF_Random(n, seed, 'perm') is this permutation plus 1.)

Returns:

A 1-D array of length n (float for ‘uniform’ and ‘normal’, int for ‘perm’).

Return type:

numpy.ndarray