Skip to main content
Module

x/statistics/mod.ts

Deno basic statistics module.
Latest
import * as mod from "https://deno.land/x/statistics@v0.1.1/mod.ts";

Functions

When adding a new value to a list, one does not have to necessary recompute the mean of the list in linear time. They can instead use this function to compute the new mean by providing the current mean, the number of elements in the list that produced it and the new value to add.

The Geometric Mean is a mean function that is more useful for numbers in different ranges.

The Harmonic Mean is a mean function typically used to find the average of rates. This mean is calculated by taking the reciprocal of the arithmetic mean of the reciprocals of the input numbers.

This computes the maximum number in an array.

The maximum is the highest number in the sorted array. With a sorted array, the last element in the array is always the largest, so this calculation can be done in one step, or constant time.

The mean, also known as average, is the sum of all values over the number of values. This is a measure of central tendency: a method of finding a typical or central value of a set of numbers.

The median is the middle number in a sorted, ascending or descending, list of numbers and can be more descriptive of that data set than the average.

The min is the lowest number in the array. This runs on O(n), linear time in respect to the array

The minimum is the lowest number in the sorted array. With a sorted array, the first element in the array is always the smallest, so this calculation can be done in one step, or constant time.

The mode is the number that appears in a list the highest number of times. There can be multiple modes in a list: in the event of a tie, this algorithm will return the most recently seen mode.

The mode is the number that appears in a list the highest number of times. There can be multiple modes in a list: in the event of a tie, this algorithm will return the most recently seen mode.

The product of an array is the result of multiplying all numbers together, starting using one as the multiplicative identity.

The quantile: this is a population quantile, since we assume to know the entire dataset in this library. This is an implementation of the Quantiles of a Population algorithm from wikipedia.

This is the internal implementation of quantiles: when you know that the order is sorted, you don't need to re-sort it, and the computations are faster.

The Root Mean Square (RMS) is a mean function used as a measure of the magnitude of a set of numbers, regardless of their sign. This is the square root of the mean of the squares of the input numbers. This runs on O(n), linear time in respect to the array

The sample standard deviation is the square root of the sample variance.

The sample variance is the sum of squared deviations from the mean. The sample variance is distinguished from the variance by the usage of Bessel's Correction: instead of dividing the sum of squared deviations by the length of the input, it is divided by the length minus one. This corrects the bias in estimating a value from a set that you don't know if full.

The standard deviation is the square root of the variance. This is also known as the population standard deviation. It's useful for measuring the amount of variation or dispersion in a set of values.

Our default sum is the Kahan-Babuska algorithm. This method is an improvement over the classical Kahan summation algorithm. It aims at computing the sum of a list of numbers while correcting for floating-point errors. Traditionally, sums are calculated as many successive additions, each one with its own floating-point roundoff. These losses in precision add up as the number of numbers increases. This alternative algorithm is more accurate than the simple way of calculating sums by simple addition.

The sum of deviations to the Nth power. When n=2 it's the sum of squared deviations. When n=3 it's the sum of cubed deviations.

The simple sum of an array is the result of adding all numbers together, starting from zero.

The variance is the sum of squared deviations from the mean.