Skip to content

gaussian

Created: 2017-10-02 14:05:53 -0700 Modified: 2017-10-02 14:15:52 -0700

Pronunciation: “gow-see-an” (no “sh” sound)

There’s a library called gaussian that can generate numbers according to a normal distribution.

There’s a lot of really helpful information about normal distributions here. Of particular interest is this quote:

About 68% of values drawn from a normal distribution are within one standard deviationσaway from the mean; about 95% of the values lie within two standard deviations; and about 99.7% are within three standard deviations. This fact is known as the68-95-99.7 (empirical) rule, or the3-sigma rule.

2:13 IAMABananaAMAA: @Adam13531 make sure you don’t confuse CDF and PDF. CDF is saying “I’m better than X% of people”. PDF is saying “There’s an X% chance of somebody having my rank”

This code generates a ton of numbers according to a normal distribution and then prints out overall statistics at the end:

const _ = require('lodash');
const gaussian = require('gaussian');
const distribution = gaussian(1200, 50000);
const numTrials = 1000000;
const trials = _.times(numTrials, () => {
return distribution.ppf(Math.random());
});
const min = _.min(trials);
const max = _.max(trials);
const mean = _.mean(trials);
console.log('min: ' + JSON.stringify(min));
console.log('max: ' + JSON.stringify(max));
console.log('mean: ' + JSON.stringify(mean));

Sample output:

min: 137.72344398219911

max: 2281.1738332887217

mean: 1200.1246440963916