ALFI
Advanced Library for Function Interpolation
|
Functions | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
Number | mean (const Container< Number > &container) |
Calculates the arithmetic mean of the elements in a container. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
Number | mean_abs (const Container< Number > &container) |
Calculates the arithmetic mean of the absolute values of the elements in a container. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
Number | mean_square (const Container< Number > &container) |
Calculates the arithmetic mean the squares of the elements in a container. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
Number | rms (const Container< Number > &container) |
Calculates the root mean square (RMS) of the elements in a container. | |
template<typename Number = DefaultNumber, template< typename, typename... > class Container = DefaultContainer> | |
Number | var (const Container< Number > &container, bool biased=false) |
Calculates the variance of the elements in a container. | |
Number alfi::util::stat::mean | ( | const Container< Number > & | container | ) |
Calculates the arithmetic mean of the elements in a container.
The arithmetic mean is calculated as:
\[ mean = \frac{1}{n} \sum_{i=1}^{n} x_i \]
where \(n\) is the number of elements in the container, and \(x_i\) are the elements.
If the container is empty, the function returns 0.
container | the container holding the elements |
Number alfi::util::stat::mean_abs | ( | const Container< Number > & | container | ) |
Calculates the arithmetic mean of the absolute values of the elements in a container.
The mean absolute value is calculated as:
\[ mean\_abs = \frac{1}{n} \sum_{i=1}^{n} |x_i| \]
where \(n\) is the number of elements in the container, and \(x_i\) are the elements.
If the container is empty, the function returns 0.
container | the container holding the elements |
Number alfi::util::stat::mean_square | ( | const Container< Number > & | container | ) |
Calculates the arithmetic mean the squares of the elements in a container.
The mean square is calculated as:
\[ mean\_square = \frac{1}{n} \sum_{i=1}^{n} x_i^2 \]
where \(n\) is the number of elements in the container, and \(x_i\) are the elements.
If the container is empty, the function returns 0.
container | the container holding the elements |
Number alfi::util::stat::rms | ( | const Container< Number > & | container | ) |
Calculates the root mean square (RMS) of the elements in a container.
The root mean square is calculated as:
\[ rms = \sqrt{\frac{1}{n} \sum_{i=1}^{n} x_i^2} \]
where \(n\) is the number of elements in the container, and \(x_i\) are the elements.
If the container is empty, the function returns 0.
container | the container holding the elements |
Number alfi::util::stat::var | ( | const Container< Number > & | container, |
bool | biased = false ) |
Calculates the variance of the elements in a container.
The variance is calculated as:
\[ var = \frac{1}{n-1} \sum_{i=1}^{n} (x_i - \mu)^2 \]
for an unbiased estimate, where \(n\) is the number of elements, \(x_i\) are the elements, and \(\mu\) is the mean of the elements.
For a biased estimate, the formula is:
\[ var = \frac{1}{n} \sum_{i=1}^{n} (x_i - \mu)^2 \]
If the container has fewer than two elements, the function returns 0.
container | the container holding the elements |
biased | If false (default), calculates the unbiased variance (divides by \(n-1\)); if true, calculates the biased variance (divides by \(n\)). |