Both of the above solutions are non-skewed/uniform distributions, which is easily done with existing event commands or a simple
min + Math.randomInt(max - min + 1)
script call.
When referring to a probability distribution, the word "normalised" means that if you multiply every possible output value by its probability over the distribution's domain, the answer is 1 (i.e. 100%). This has nothing to do with the normal (a.k.a. Gaussian) distribution.
Incidentally, the normal distribution is typically used for analysing a data set, rather than generating or skewing random numbers. Hence its characterisation in terms of mean and standard deviation.
You can naively skew a uniform RNG by passing the uniform value through the skew function, e.g. skewing
Math.random
(uniform on
[0, 1)
) through
f(x) = x²
:
JavaScript:
Math.pow(Math.random(), 2)
Then you can do the usual multiplying/rounding to get whatever kind of value you like. However, this does not guarantee that the skewed RNG will be normalised.
I think this represents a Gaussian curve?
JavaScript:
function gaussian(x, mean, dev) {
// exp(-(x-μ)²/2σ²) / σ√2π
return Math.exp(
-Math.pow((x - mean) / dev, 2) / 2
) / (dev * Math.SQRT1_2 / Math.sqrt(Math.PI));
}
So in theory you may be able to use that. I'd suggest using a polynomial or something instead, though. If you want to normalise the Gaussian-skewed result then things get complicated because that curve's integral requires numerical approximation.
(Hopefully I haven't misinterpreted and written that all out for nothing.

)