A library for working with phylogenetic and population genetic data.
v0.27.0
statistics.hpp File Reference
#include "genesis/utils/core/algorithm.hpp"
#include "genesis/utils/math/common.hpp"
#include "genesis/utils/math/ranking.hpp"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstddef>
#include <functional>
#include <limits>
#include <stdexcept>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  MeanStddevPair
 Store a mean and a standard deviation value. More...
 
struct  MinMaxPair< T >
 Store a pair of min and max values. More...
 
struct  Quartiles
 Store the values of quartiles: q0 == min, q1 == 25%, q2 == 50%, q3 == 75%, q4 == max. More...
 

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::utils
 

Enumerations

enum  HarmonicMeanZeroPolicy { kThrow, kIgnore, kReturnZero, kCorrection }
 Select a policy on how to treat zeroes in the computation of harmonic_mean() and weighted_harmonic_mean(). More...
 

Functions

template<class ForwardIterator >
double arithmetic_mean (ForwardIterator first, ForwardIterator last)
 Calculate the arithmetic mean of a range of numbers. More...
 
double arithmetic_mean (std::vector< double > const &vec)
 Calculate the arithmetic mean of a std::vector of double elements. More...
 
template<class ForwardIterator >
void closure (ForwardIterator first, ForwardIterator last)
 Calculate the closure of a range of numbers. More...
 
void closure (std::vector< double > &vec)
 Calculate the closure of a std::vector of double elements. More...
 
double coefficient_of_variation (MeanStddevPair const &ms)
 Calculate the index of dispersion. More...
 
std::vector< double > coefficient_of_variation (std::vector< MeanStddevPair > const &ms)
 Calculate the index of dispersion. More...
 
template<class ForwardIterator >
std::pair< size_t, size_t > count_finite_elements (ForwardIterator first, ForwardIterator last)
 Count the number of finite elements in a range of double values. More...
 
template<class ForwardIterator >
double finite_maximum (ForwardIterator first, ForwardIterator last)
 Return the maximum of a range of double values. More...
 
template<class ForwardIterator >
double finite_minimum (ForwardIterator first, ForwardIterator last)
 Return the minimum of a range of double values. More...
 
template<class ForwardIterator >
MinMaxPair< double > finite_minimum_maximum (ForwardIterator first, ForwardIterator last)
 Return the minimum and the maximum of a range of double values. More...
 
double fisher_transformation (double correlation_coefficient)
 Apply Fisher z-transformation to a correlation coefficient. More...
 
std::vector< double > fisher_transformation (std::vector< double > const &correlation_coefficients)
 Apply Fisher z-transformation to a vector of correlation coefficients. More...
 
template<class ForwardIterator >
double geometric_mean (ForwardIterator first, ForwardIterator last)
 Calculate the geometric mean of a range of positive numbers. More...
 
double geometric_mean (std::vector< double > const &vec)
 Calculate the geometric mean of a std::vector of double elements. More...
 
template<class ForwardIterator >
double harmonic_mean (ForwardIterator first, ForwardIterator last, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow)
 Calculate the harmonic mean of a range of positive numbers. More...
 
double harmonic_mean (std::vector< double > const &vec, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow)
 Calculate the harmonic mean of a std::vector of double elements. More...
 
double index_of_dispersion (MeanStddevPair const &ms)
 Calculate the index of dispersion. More...
 
std::vector< double > index_of_dispersion (std::vector< MeanStddevPair > const &ms)
 Calculate the index of dispersion. More...
 
template<class ForwardIterator >
MeanStddevPair mean_stddev (ForwardIterator first, ForwardIterator last, double epsilon=-1.0)
 Calculate the arithmetic mean and standard deviation of a range of double elements. More...
 
MeanStddevPair mean_stddev (std::vector< double > const &vec, double epsilon=-1.0)
 Calculate the mean and standard deviation of a std::vector of double elements. More...
 
template<class RandomAccessIterator >
double median (RandomAccessIterator first, RandomAccessIterator last)
 Calculate the median value of a sorted range of double values. More...
 
double median (std::vector< double > const &vec)
 Calculate the median value of a vector of double. More...
 
template<class ForwardIteratorA , class ForwardIteratorB >
double pearson_correlation_coefficient (ForwardIteratorA first_a, ForwardIteratorA last_a, ForwardIteratorB first_b, ForwardIteratorB last_b)
 Calculate the Pearson Correlation Coefficient between two ranges of double. More...
 
double pearson_correlation_coefficient (std::vector< double > const &vec_a, std::vector< double > const &vec_b)
 Calculate the Pearson Correlation Coefficient between the entries of two vectors. More...
 
double quartile_coefficient_of_dispersion (Quartiles const &q)
 Calculate the quartile_coefficient_of_dispersion. More...
 
std::vector< double > quartile_coefficient_of_dispersion (std::vector< Quartiles > const &q)
 Calculate the quartile_coefficient_of_dispersion. More...
 
template<class RandomAccessIterator >
Quartiles quartiles (RandomAccessIterator first, RandomAccessIterator last)
 Calculate the Quartiles of a sorted range of double values. More...
 
Quartiles quartiles (std::vector< double > const &vec)
 Calculate the Quartiles of a vector of double. More...
 
template<class RandomAccessIteratorA , class RandomAccessIteratorB >
double spearmans_rank_correlation_coefficient (RandomAccessIteratorA first_a, RandomAccessIteratorA last_a, RandomAccessIteratorB first_b, RandomAccessIteratorB last_b)
 Calculate Spearman's Rank Correlation Coefficient between two ranges of double. More...
 
double spearmans_rank_correlation_coefficient (std::vector< double > const &vec_a, std::vector< double > const &vec_b)
 Calculate Spearman's Rank Correlation Coefficient between the entries of two vectors. More...
 
template<class ForwardIterator >
double weighted_arithmetic_mean (ForwardIterator first_value, ForwardIterator last_value, ForwardIterator first_weight, ForwardIterator last_weight)
 Calculate the weighted arithmetic mean of a range of double values. More...
 
double weighted_arithmetic_mean (std::vector< double > const &values, std::vector< double > const &weights)
 Calculate the weighted arithmetic mean of a std::vector of double elements. More...
 
template<class ForwardIterator >
double weighted_geometric_mean (ForwardIterator first_value, ForwardIterator last_value, ForwardIterator first_weight, ForwardIterator last_weight)
 Calculate the weighted geometric mean of a range of positive numbers. More...
 
double weighted_geometric_mean (std::vector< double > const &values, std::vector< double > const &weights)
 Calculate the weighted geometric mean of a std::vector of double elements. More...
 
template<class ForwardIterator >
double weighted_harmonic_mean (ForwardIterator first_value, ForwardIterator last_value, ForwardIterator first_weight, ForwardIterator last_weight, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow)
 Calculate the weighted harmonic mean of a range of positive numbers. More...
 
double weighted_harmonic_mean (std::vector< double > const &values, std::vector< double > const &weights, HarmonicMeanZeroPolicy zero_policy=HarmonicMeanZeroPolicy::kThrow)
 Calculate the weighted harmonic mean of a std::vector of double elements. More...