How do you even measure an algorithm’s randomness? If this is just for fun then I think it’s good practice but if this is for a bigger project I wouldn’t focus on something as minor as this and just use the default random functions.
If you want any form of true randomness generation within Roblox its most likely better to connect up to a server that can provide cryptographic/near true random.
However for this particular equation you might want to look at what other peoples solutions have done in other languages that can be mostly converted over to luau nicely. Here you can find a Box-Mueller random number generator in C# which you can convert over:
Here is another implementation but in C++:
Another thing to remember is that all random generation requires an input that is also random, so you may need to source that randomness from somewhere. A possible creative way to do this is to take all the users connected mouse movements and generate from that.
Theres no way to make ur own algorithm in lua, yet alone luau which removes features from lua. Your best bet is to make ur own c++ api which ur roblox lua sever sends a request to. U should use c++ as it’s a very powerful language so you can easily create your own algorithm in it.
The box-muller transform is used to take a uniform distribution and turn it into a normal distribution. In two dimensions, basically.
You would input 2 numbers, generated using Random.new(), which has a uniform distribution.
Then it would give you 2 numbers with a normal distribution.
To implement it, I think the math library should be enough. The Theta represents the angle, and R the radius, when you would write polar coordinates. But you can just ignore that part in the middle, and take the right and convert it into the left.
Calculating distributions will be very inefficient, as we cannot do vector operations on batches of numbers. But I guess for individual numbers its a fine solution.
So if you need only one normally distributed (with mean zero and variance 1) number, just take two numbers from Random.new() (between 0 and 1) and send them as U1 and U2 through either of the formulas, I think.
Disclaimer: I never used or implemented this so I may have gotten things wrong. X) There are also other ways to do the same.
Edit: Whoops, mistake, a normal distribution is unbounded. The resulting normal distribution has mean 0 and variance 1, so the output is not (neccessarily) in the range [0,1]. Corrected it.