UNPKG

normal-distribution

Version:

A small javascript module for working with normal distributions

50 lines (49 loc) 1.72 kB
/** * Rounds a value to a specified amount of decimal places * @param {number} value - the value to be rounded * @param {number} decimalPlaces - the amount of decimal places to round to * @return {number} the rounded number */ export default class NormalDistribution { mean: number; standardDeviation: number; /** * The constructor, assumes a standardized normal distribution if * there are no parameters given * @param {number} [mean=0] - the mean average * @param {number} [standardDeviation=1] - the standard deviation */ constructor(mean?: number, standardDeviation?: number); /** * @param {number} value - the number to convert to a z-score * @return {number} the z-score of the value */ zScore(value: number): number; /** * Return the probability of finding x in the distribution * @param {number} value - the value to evaluate * @return {number} the probability */ pdf(value: number): number; /** * Return the cumalitive probability for everything left of the value * @param {number} value - the value to evaluate * @return {number} the cumulative total */ cdf(value: number): number; /** * Return the probability of a value in the distribution being * between two values * @param {number} value1 - the first boundary * @param {number} value2 - the second boundary * @return {number} the probability */ probabilityBetween(value1: number, value2: number): number; /** * Returns an object representing the standardized z-table * @return {Object} the zTable */ static get zTable(): { [key: string]: number[]; }; }