deno.land / x / simplestatistic@v7.7.1 / src / add_to_mean.js

add_to_mean.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/** * 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. * * @since 2.5.0 * @param {number} mean current mean * @param {number} n number of items in the list * @param {number} newValue the added value * @returns {number} the new mean * * @example * addToMean(14, 5, 53); // => 20.5 */function addToMean(mean, n, newValue) { return mean + (newValue - mean) / (n + 1);}
export default addToMean;
simplestatistic

Version Info

Tagged at
2 years ago