Statistics
Collection of statistical functions.
Methods
mean
mean(values: number[])
Calculates the average for given array of values.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
mode
mode(values: number[])
Calculates the most frequent occurring value(s) within a given array. Returns a single value. In the case of multiple modes, this will return the lowest value.
Parameters
values number[]
The array of values on which the mode is deducted.
Return type
number
Examples
modes
modes(values: number[])
Calculates the most frequent occurring value(s) within a given array. Returns an array.
Parameters
values number[]
The array of values on which the mode is deducted.
Return type
number[]
Examples
median
median(values: number[])
Returns the median, or the number in the middle of the given array.
Parameters
values number[]
The array of values on which the median is calculated.
Return type
number
Examples
slope
slope(knownYvalues: number[], knownXvalues?: number[])
Calculates the slope for a given number of points. If the x-values are omitted, the assumption is that all x-values have corresponding consecutive y-values [1 .. nr of x-values]. X-values may be numeric or of type Year ("YYYY") or YearMonth ("YYYY-MM").
Parameters
knownYvalues number[]
The array of values on which the calculation is made.
knownXvalues number[]
(optional) The x-values array. If omitted, the x-values are generated as 1,2,3...n for the number of y-values
Return type
number
Examples
intercept
intercept(knownYvalues: number[], knownXvalues?: number[])
Calculates the intercept (the value at the intersection of the y axis) of the linear regression line through a supplied set of x-values. If the x-values are omitted, the assumption is that all x-values have corresponding consecutive y-values [1 .. nr of x-values]. X-values may be numeric or of type Year ("YYYY") or YearMonth ("YYYY-MM")
Parameters
knownYvalues number[]
The array of values on which the calculation is made.
knownXvalues number[]
(optional) The x-values array. If omitted, the x-values are generated as 1,2,3...n for the number of y-values. X-values may be numeric or of type Year ("YYYY") or YearMonth ("YYYY - MM")
Return type
number
Examples
rsq
rsq(knownYvalues: number[], knownXvalues?: number[])
Returns the square of the Pearson product moment correlation coefficient. If the x-values are omitted, the assumption is that all x-values have corresponding consecutive y-values [1 .. nr of x-values]. X-values may be numeric or of type Year ("YYYY") or YearMonth ("YYYY-MM")
Parameters
knownYvalues number[]
The array of values on which the calculation is made.
knownXvalues number[]
(optional) The x-values array. If omitted, the x-values are generated as 1,2,3...n for the number of y-values. X-values may be numeric or of type Year ("YYYY") or YearMonth ("YYYY - MM")
Return type
number
Examples
varP
varP(values: number[])
Calculates variance based on the entire population and assumes that its arguments are the entire population. If your data represents a sample of the population, then compute the variance by using VarS.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
varS
varS(values: number[])
Calculates variance based on a sample and assumes that its arguments are a sample of the population. If your data represents the entire population, then compute the variance by using VarP.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
stdDevP
stdDevP(values: number[])
Returns the standard deviation based on the entire population given as arguments.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
stdDevS
stdDevS(values: number[])
Returns the standard deviation based on a sample list of values.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
stdErrorP
stdErrorP(values: number[])
Returns the standard error based on the entire population given as arguments.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
stdErrorS
stdErrorS(values: number[])
Returns the standard error based on a sample list of values.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
normalRandom
normalRandom(mean: number, stdDev: number)
Returns a random number from a normal distribution.
Parameters
mean number
The mean or expectation of the distribution.
stdDev number
The standard deviation of the distribution.
Return type
number
Examples
normalDistribution
normalDistribution(mean: number, stdDev: number, nrOfValues: number)
Returns [nrOfValues] random numbers from a normal distribution.
Parameters
mean number
The mean or expectation of the distribution.
stdDev number
The standard deviation of the distribution.
nrOfValues number
The number of random numbers returned.
Return type
number[]
Examples
gammaRandom
gammaRandom(alpha: number, beta: number)
Returns a random number from a gamma distribution.
Parameters
alpha number
The shape of the distribution. Should be a positive number.
beta number
The rate of the distribution. Should be a positive integer value.
Return type
number
Examples
gammaDistribution
gammaDistribution(alpha: number, beta: number, nrOfValues: number)
Returns [nrOfValues] random numbers from a gamma distribution.
Parameters
alpha number
The shape of the distribution. Should be a positive number.
beta number
The rate of the distribution. Should be a positive integer value.
nrOfValues number
The number of random numbers returned.
Return type
number[]
Examples
meanAbsDev
meanAbsDev(values: number[])
Returns the Mean Absolute Deviation.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
medianAbsDev
medianAbsDev(values: number[])
Returns the Median Absolute Deviation.
Parameters
values number[]
The array of values on which the calculation is made.
Return type
number
Examples
findGaps
findGaps(values: T[])
Returns missing values in an array. Values could be of type number or YearMonth strings
Parameters
values T[]
The array of values in which we look for missing values.
Return type
T[]
Examples
fillGaps
fillGaps(values: T[])
Adds the missing values to an array. Values could be of type number or YearMonth strings
Parameters
values T[]
The array of values in which we look for missing values.
Return type
T[]
Examples
Last updated