Skip to content

Instantly share code, notes, and snippets.

@vndee
Last active November 1, 2024 13:43
Show Gist options
  • Save vndee/59339360cc547247175dfac4cfbb2090 to your computer and use it in GitHub Desktop.
Save vndee/59339360cc547247175dfac4cfbb2090 to your computer and use it in GitHub Desktop.
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