Mojo module
philox
Random number generation using the Philox algorithm.
This module implements a high-performance random number generator using the Philox algorithm, which is designed for parallel computing and works efficiently on both CPU and GPU. The Philox algorithm is a counter-based random number generator that provides high-quality random numbers with excellent statistical properties.
The main class is Random which generates both uniform random numbers and raw 32-bit integers. It supports:
- Seeding for reproducible sequences
- Multiple independent subsequences
- Configurable number of rounds for quality vs performance tradeoff
- Vectorized operations for efficiency
- Cross-platform support (CPU and GPU)
Example:
from random.philox import Random
rng = Random(seed=42)
uniform_values = rng.step_uniform() # Returns 4 random floats in [0,1)
raw_values = rng.step() # Returns 4 raw 32-bit integersStructsโ
- โ
NormalRandom: A high-performance random number generator using the Box-Muller transform. - โ
Random: A high-performance random number generator using the Philox algorithm.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!