JavaScript Seedable Gaussian Random Numbers

Just for fun I thought I’d code up a JavaScript function that emits Gaussian random numbers, and I wanted the generator to be reproducible (seedable).

I wrote a crude seedable uniform random number generator using some hacky code I found online, and then leveraged that function to write a function that emits Gaussians (using the Box-Muller algorithm).


I demoed my function in a Web page. To perform a sanity check, I generated 2,000 random Gaussians with mean = 0.0 and sd = 1.0, and graphed the result in Excel. I did that twice. The numbers look reasonably Gaussian. Good enough for simple tasks.



This entry was posted in Machine Learning, Miscellaneous. Bookmark the permalink.