Last active
November 1, 2024 13:43
-
-
Save vndee/59339360cc547247175dfac4cfbb2090 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def random_float(mt): | |
"""Generate a random float in [0.0, 1.0)""" | |
return mt.extract_number() / 0xffffffff # Divide by 2^32 - 1 | |
def uniform(mt, a, b): | |
"""Generate a random float in [a, b)""" | |
return a + (b - a) * random_float(mt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment