ActivitySim Random Number Generator
Updating the RNG for use in Explicit Error Terms -- Introduction
Last Updated: March 2026
EET Work Pointed to Need for RNG Improvements
Running with Explicit Error Terms requires many more random number draws
2
ActivitySim has Specific Requirements for its RNG
3
Starting to look at RNG Options and Build Tests
4
Option | How it works | Pros | Cons |
RandomState | ActivitySim's current option: Uses NumPy’s older random engine. For each chooser, it resets to that chooser’s seed, then draws numbers. | Familiar, stable, easy to trust | Older/slower than newer methods |
GeneratorPCG64 | Uses NumPy’s newer Generator with PCG64. Also reseeds per chooser before drawing. | Modern default quality, reproducible, clearer future path than RandomState | Still does a lot of per-chooser setup, so not the fastest |
GeneratorSFC64 | Same style as above but uses the SFC64 engine. | Often very fast, reproducible | Results differ from PCG64, and speed can vary by workload |
GeneratorPhilox | Same style but uses Philox engine. | Strong reproducibility, good parallel-friendly design | May not be fastest for your specific workload |
GeneratorMT19937 | Same style but uses Mersenne Twister engine. | Very well-known and widely used historically | Not the most modern choice, can be slower than newer engines |
PhiloxAdvance | Philox-based approach that can jump ahead when offset is used, instead of stepping one-by-one. | Better behavior when fast-forward/offset is large; reproducible | More specialized; may not always beat simpler options |
VectorizedChooserHash | Uses a fast “hash-like” method that generates numbers for many choosers at once, while keeping each chooser independent of others. | Very fast for batch work, seed-invariant by chooser, supports both replacement and non-replacement choice | Not a standard NumPy engine like PCG64/Philox; different statistical style than those families |
Building Evaluation Tool to Compare RNGs
5
Preliminary Results
RNG performance is a trade-off between reseeding speed and sampling speed
Next Steps
Just getting started
7