Simulating Non-Uniform Distributions

Overview


Once you have a generator for a uniform distribution, you can get a generator for any distribution for which you have a function that is the inverse cumulative function, using the following formula.
{% X = F^{-1}(U) %}
The following code generates 100 samples taken from a normal distribution by using the inverse cumulative normal function.


let nm = await import('/lib/statistics/distributions/normal/v1.0.0/normal.js');
let sample = [];
for(let i=0;i<100;i++){ 
	sample.push(nm.invCumulative(Math.random()));
}