randomgen.philox.Philox.advance

Philox.advance(delta, counter=False)

Advance the underlying RNG as-if delta draws have occurred.

Parameters:
delta

Number of draws to advance the RNG. Must be less than the size state variable in the underlying RNG. delta can take any value and can be negative. Values outside 0 and 2**(N*W+N/2) are converted into this range by taking the modulo.

counter=False

Flag indicating whether to advance the counter only or both the counter and the buffer position. If False, the generator is advanced by delta draws, as if delta values had been drawn using random_raw. If True, the counter is advanced by delta and any buffered values are discarded, so that delta counts blocks of number draws. This was the default in earlier releases. To convert between the two, use delta_draws = delta_blocks * number where number is the number of elements in the generator.

Returns:

self – RNG advanced delta steps

Return type:

Philox

Notes

Advancing a RNG updates the underlying RNG state as-if a given number of calls to the underlying RNG have been made. In general there is not a one-to-one relationship between the number output random values from a particular distribution and the number of draws from the core RNG. This occurs for two reasons:

  • The random values are simulated using a rejection-based method and so, on average, more than one value from the underlying RNG is required to generate an single draw.

  • The number of bits required to generate a simulated value differs from the number of bits generated by the underlying RNG. For example, two 16-bit integer values can be simulated from a single draw of a 32-bit RNG.

Advancing the RNG state resets any stored 32-bit values. If counter is True, it also resets the buffer and buffer position.