3 ms·
A while ago I tried to create a more self-explanatory implementation: https://github.com/tmoertel/practice/blob/master/libraries%2Fdiscrete_random_variables.py
by tmoertel 1y ago
A while ago I tried to create a more self-explanatory implementation:
https://github.com/tmoertel/practice/blob/master/libraries%2Fdiscrete_random_variables.py https://github.com/tmoertel/practice/blob/master/libraries%2...
It is limited to integer weights only to make it easy to verify that the algorithm implements the requested distribution exactly. (See the test file in the same directory.)
- eru 1y agoYou could probably restrict to rational numbers, and still verify? Languages like Python, Haskell, Rust etc have good support for arbitrary length rational numbers. Each floating point number is also a rational number, and thus you could then restrict again to floating point afterwards.