One way to generate a normally distributed random number in JavaScript is to use the Box-Muller transform. Here's an implementation of the transform:
index.tsx300 chars9 lines
This function takes two parameters: mean (the mean of the normal distribution) and standardDeviation (the standard deviation of the normal distribution). It returns a single random number from the specified normal distribution.
You can call this function like this:
index.tsx135 chars5 lines
This will generate a normally distributed random number with a mean of 0 and a standard deviation of 1.
gistlibby LogSnag