addToMean
addToMean(
mean,n,newValue):number
Defined in: src/add_to_mean.js:17
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.
Parameters
Section titled “Parameters”number
current mean
number
number of items in the list
newValue
Section titled “newValue”number
the added value
Returns
Section titled “Returns”number
the new mean
2.5.0
Example
Section titled “Example”addToMean(14, 5, 53); // => 20.5