Skip to main content

Module pyrandom

Module pyrandom 

Source
Expand description

A bit-compatible port of CPython’s random.Random (Mersenne Twister, MT19937), so ensemble member generation can be validated numerically against the real TabFMClassifier/ TabFMRegressor sklearn wrapper (which seeds random.Random(random_state) and calls .sample()/.shuffle() in a specific order — see config_gen.rs).

Ported from CPython’s Modules/_randommodule.c (MT19937 core, init_by_array seeding) and Lib/random.py (_randbelow, sample, shuffle). Reference sequences used in the unit tests below were generated with the project’s own .venv/bin/python3.

Structs§

Mt19937
PyRandom
A CPython-compatible random.Random instance: MT19937 state plus the pure-Python wrapper logic (_randbelow, sample, shuffle) from Lib/random.py.