Skip to main content
Module

x/simplestatistics/src/subtract_from_mean.js

simple statistics for node & browser javascript
Go to Latest
File
/** * When removing a value from 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 value to remove. * * @since 3.0.0 * @param {number} mean current mean * @param {number} n number of items in the list * @param {number} value the value to remove * @returns {number} the new mean * * @example * subtractFromMean(20.5, 6, 53); // => 14 */function subtractFromMean(mean, n, value) { return (mean * n - value) / (n - 1);}
export default subtractFromMean;