1.1.1 • Published 6 years ago

jsboxmuller v1.1.1

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

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:

ParameterDescription
meanMean value for random variable
varianceVariance of the distribution

If parameters are skipped, function will generate numbers from distribution with mean value of 0.0 and unit variance.

const bm = require('jsboxmuller');

let a = new Array(100);
for(let i=0; i<100; ++i) {
  a[i] = bm();
}

// Array contains values from normal distribution with mean 0.0 and variance 1.0
console.log(a);

// x and y in distribution with mean 12.0 and variance 0.2
let x = bm(12, 0.2); 
let y = bm() * 0.2 + 12;
1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago