mt_rng

numcodecs_random_projection.mt_rng

Classes:

  • MultithreadedRNG

    Multithreaded random number generator using numpy's PCG64 generator

MultithreadedRNG

MultithreadedRNG(seed: int, threads: None | int = None)

Multithreaded random number generator using numpy's PCG64 generator Based on https://numpy.org/doc/stable/reference/random/multithreading.html.

Initialize the multithreaded RNG.

Parameters:
  • seed (int) –

    The seed for the random number generator.

  • threads (int, default: None ) –

    The number of threads to use. If None, uses the number of CPU cores.

Methods:

  • fill_arr

    Fill a 2D array with random numbers in parallel using threads.

fill_arr

fill_arr(
    *, out: ndarray[tuple[int, int], dtype[floating]]
) -> None

Fill a 2D array with random numbers in parallel using threads.

The number of RNG chunks is determined by the shape, so results are reproducible regardless of the number of threads used.

Parameters: