Skip to content

Comment on Zero Tolerance for Biasparent

Comments

A real pendant would handle collisions

If Math.random() is truly uniform, it has about 53 bits of entropy. We can find the likelyhood of a collision with the birthday paradox

... the post ends here because WolframAlpha keeps choking on computations with numbers very, very close to one. I'm not doing derivatives.

Fun fact: Math.random(a,b) always has about 53 bits of randomness, unless b/a is close to 1

You can calculate the probabilities and expected number of collisions analytically, but evaluating the expressions numerically is tricky for large numbers. I can recommend https://herbie.uwplse.org/ to rewrite the expressions into a form that can be evaluated.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.