Skip to main content
Module

x/statistics/mod.ts>addToMean

Deno basic statistics module.
Latest
function addToMean
import { addToMean } from "https://deno.land/x/statistics@v0.1.1/mod.ts";

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.

Examples

addToMean(14, 5, 53); // => 20.5

Parameters

mean: number

current mean

n: number

number of items in the list

newValue: number

the added value

Returns

number

the new mean