mean

fnT mean(T = double, R)(R r) if (isInputRange!R && isNumeric!(ElementType!R) && !isInfinite!R)

Finds the mean (colloquially known as the average) of a range.

For built-in numerical types, accurate Knuth & Welford mean calculation is used. For user-defined types, element by element summation is used. Additionally an extra parameter seed is needed in order to correctly seed the summation with the equivalent to 0.

The first overload of this function will return T.init if the range is empty. However, the second overload will return seed on empty ranges.

This function is r.length.

Parameters

TThe type of the return value.
rAn input range
seedFor user defined types. Should be equivalent to 0.

Returns

The mean of r when r is non-empty.
fnauto mean(R, T)(R r, T seed) if (isInputRange!R && !isNumeric!(ElementType!R) && is(typeof(r.front + seed)) && is(typeof(r.front / size_t(1))) && !isInfinite!R)

ditto