23 Number
mean(
const Container<Number>& container) {
24 if (container.empty()) {
28 for (
const auto& value : container) {
31 return sum / container.size();
49 Number
mean_abs(
const Container<Number>& container) {
50 if (container.empty()) {
54 for (
const auto& value : container) {
55 sum += std::abs(value);
57 return sum / container.size();
76 if (container.empty()) {
80 for (
const auto& value : container) {
83 return sum / container.size();
101 Number
rms(
const Container<Number>& container) {
126 Number
var(
const Container<Number>& container,
bool biased =
false) {
127 if (container.size() <= 1) {
130 const auto m =
mean(container);
132 for (
const auto& value : container) {
133 sum += (value - m) * (value - m);
135 return sum / (biased ? container.size() : container.size() - 1);
Number var(const Container< Number > &container, bool biased=false)
Calculates the variance of the elements in a container.
Definition stat.h:126
Number mean_square(const Container< Number > &container)
Calculates the arithmetic mean the squares of the elements in a container.
Definition stat.h:75
Number rms(const Container< Number > &container)
Calculates the root mean square (RMS) of the elements in a container.
Definition stat.h:101
Number mean_abs(const Container< Number > &container)
Calculates the arithmetic mean of the absolute values of the elements in a container.
Definition stat.h:49
Number mean(const Container< Number > &container)
Calculates the arithmetic mean of the elements in a container.
Definition stat.h:23
ALFI_DEFAULT_NUMBER DefaultNumber
Definition config.h:17
ALFI_DEFAULT_CONTAINER< Number > DefaultContainer
Definition config.h:20