I'm trying to create a exponential random number generator using JavaScript, which works using methods from a previous StackOverflow answer. :
function randomNumGen() {
var u = Math.random();
var mu = 0.3;
return -Math.log(1.0 - u) / mu;
}
However, I later discovered that using Math.random()
is not cryptographically secure from another StackOverflow answer. However, I'm not entirely sure if it is cryptographically secure in my case, as it uses the uniform randomness of u
against an exponential distribution to make a sample, but I assume it isn't secure.
In the second site, it recommends other libraries, however they use different distribution, not exponential. I assume I cannot simply replace the Math.random()
with their one (e.g window.crypto.getRandomValues) as it's not uniform.
Any insights on what I can do?