Skip to content

strata::Mean

Part of Reductions.

template <typename Acc = void>
struct strata::Mean;

The sum divided by the count.

Divided by the count converted to the accumulator where it converts (a float, a complex number), by a double otherwise (a length). The mean of no values is 0 / 0: a NaN in floating point, and in integers, where it has no value, a precondition violation.

Template parameters

Name Description
Acc The accumulator type, or void for a double for integers, as in NumPy, else the type T + T gives.

Members

accumulator

template <typename T>
using strata::Mean< Acc >::accumulator = detail::mean_accumulator<Acc, T>::type

What the mean keeps while values come in.

identity

template <typename T>
constexpr accumulator<T> identity() const

The sum of no values: zero.

accumulate

template <typename A, typename T>
constexpr A accumulate(A acc, const T &value) const

acc plus one value.

combine

template <typename A>
constexpr A combine(A lhs, A rhs) const

The sum of two partial sums.

finalize

template <typename A>
constexpr auto finalize(A acc, std::size_t count) const

The sum divided by count.

Precondition

For an integer accumulator, count is not zero and fits the integer.