Box-Muller algorithm for generating normally distributed pseudo-random samples.
Installation
npm install --save jsboxmuller
Usage
Module exports a single function that returns pseudorandom numbers from normal distribution. Function takes two optional parameters:
Parameter | Description |
---|---|
mean |
Mean value for random variable |
variance |
Variance of the distribution |
If parameters are skipped, function will generate numbers from distribution with mean value
of 0.0
and unit variance.
const bm = ; let a = 100;forlet i=0; i<100; ++i ai = ; // Array contains values from normal distribution with mean 0.0 and variance 1.0console; // x and y in distribution with mean 12.0 and variance 0.2let x = ; let y = * 02 + 12;