Proving Math.Random() is random without bias

Hi,

Last night I coded a weighted roulette system of sorts with Math.Random() and let the program run for over a million spins.
Here is the result in comparison to the theoretical numbers on the notepad

Just thought it’d be fun to share and would appreciate feedback on what else I could make.

Here’s the game if you would like to check it out: Lua Testing - Roblox

1 Like

yo, forever i thought that math.random was rigged

Whilst I was making a spin system for another game I got a mythical class twice in a row which has a 4E-8 chance of happening so I assumed that Math.Random() may have bias but ig not. Probabilities are quite fascinating.

especially when I used a math.random function
every time I printed the random number, it printed in order

If you’re interested in further reading or testing, math.random and Random both use PCG-XSH-RR.

2 Likes