lundi 6 avril 2020

Probability of gettting 0.0 from random()?

I'm trying to make a simple program to demonstrate something, though I'm a bit preplexed on the math of it.

from random import random
a = random()

I read up on the random function and its distribution is [0.0;1.0). It uses Mersenne Twister to generate pseudo randoms and it's a 56bit precision floating number.

I'm assuming that means that the probability of it generating exactly 0.0 is 1/2^56?

What would a have to be lower than, in order for the probability to be 1/2^28?.. I tried understanding the 56-bit float conversion but I can't seem to figure it out. What would the actual float value have to be?

a = ?
if random() < a:
  print("Success")



Aucun commentaire:

Enregistrer un commentaire