vg
tools for working with variation graphs
Classes | Namespaces | Typedefs | Functions
statistics.hpp File Reference
#include <cmath>
#include <algorithm>
#include <map>
#include "utility.hpp"

Classes

struct  vg::SummaryStatistics
 
class  vg::uniform_real_distribution< T >
 
class  vg::normal_distribution< T >
 
class  vg::truncated_normal_distribution< T >
 
class  vg::WideningPRNG< PRNG, OutType >
 
class  vg::uniform_int_distribution< T >
 
class  vg::discrete_distribution< T >
 We provide a partial discrete_distribution implementation that is just the parts we need. More...
 

Namespaces

 vg
 

Typedefs

using vg::real_t = long double
 

Functions

double vg::median (std::vector< int > &v)
 
void vg::wellford_update (size_t &count, double &mean, double &M2, double new_val)
 
pair< double, double > vg::wellford_mean_var (size_t count, double mean, double M2, bool sample_variance)
 
template<typename T >
double vg::stdev (const T &v)
 
template<typename Number >
SummaryStatistics vg::summary_statistics (const std::map< Number, size_t > &values)
 Returns summary statistics for a multiset of numbers. More...
 
double vg::Phi (double x)
 The standard normal cumulative distribution function. More...
 
double vg::Phi_inv (double quantile)
 Inverse CDF of a standard normal distribution. Must have 0 < quantile < 1. More...
 
double vg::lognormal_pdf (double x, double mu, double sigma)
 Probability density function or log-normal distribution. More...
 
double vg::add_log (double log_x, double log_y)
 
double vg::subtract_log (double log_x, double log_y)
 
double vg::ln_to_log10 (double ln)
 
double vg::log10_to_ln (double l10)
 
double vg::log10_add_one (double x)
 
double vg::add_log10 (double i, double j)
 
double vg::phred_for_at_least_one (size_t p, size_t n)
 
double vg::prob_for_at_least_one (size_t p, size_t n)
 
template<typename T >
vg::normal_pdf (T x, T m=0.0, T s=1.0)
 
double vg::prob_to_logprob (double prob)
 Convert a probability to a natural log probability. More...
 
double vg::logprob_to_prob (double logprob)
 Convert natural log probability to a probability. More...
 
double vg::logprob_add (double logprob1, double logprob2)
 
double vg::logprob_invert (double logprob)
 Invert a logprob, and get the probability of its opposite. More...
 
double vg::phred_to_prob (uint8_t phred)
 Convert 8-bit Phred quality score to probability of wrongness, using a lookup table. More...
 
double vg::phred_to_prob (double phred)
 Convert floating point Phred quality score to probability of wrongness. More...
 
double vg::prob_to_phred (double prob)
 Convert probability of wrongness to integer Phred quality score. More...
 
double vg::phred_to_logprob (int phred)
 Convert a Phred quality score directly to a natural log probability of wrongness. More...
 
double vg::logprob_to_phred (double logprob)
 Convert a natural log probability of wrongness directly to a Phred quality score. More...
 
double vg::logprob_geometric_mean (double lnprob1, double lnprob2)
 Take the geometric mean of two logprobs. More...
 
double vg::phred_geometric_mean (double phred1, double phred2)
 Take the geometric mean of two phred-encoded probabilities. More...
 
double vg::phred_add (double phred1, double phred2)
 
template<typename Collection >
Collection::value_type vg::logprob_sum (const Collection &collection)
 
template<typename Iterator >
std::iterator_traits< Iterator >::value_type vg::phred_sum (const Iterator &begin_it, const Iterator &end_it)
 
template<typename Collection >
Collection::value_type vg::phred_sum (const Collection &collection)
 
double vg::slope (const std::vector< double > &x, const std::vector< double > &y)
 
double vg::fit_zipf (const vector< double > &y)
 
double vg::fit_fixed_shape_max_exponential (const vector< double > &x, double shape, double tolerance=1e-8)
 Returns the MLE rate parameter for the distribution of (shape) iid exponential RVs. More...
 
double vg::fit_fixed_rate_max_exponential (const vector< double > &x, double rate, double tolerance=1e-8)
 Returns the MLE estimate for the number of iid exponential RVs the data are maxima of. More...
 
pair< double, double > vg::fit_max_exponential (const vector< double > &x, double tolerance=1e-8)
 Returns the MLE rate and shape parameters of a max exponential. More...
 
double vg::max_exponential_cdf (double x, double rate, double shape, double location=0.0)
 Return the CDF of a max exponential with the given parameters. More...
 
double vg::max_exponential_log_likelihood (const vector< double > &x, double rate, double shape, double location=0.0)
 The log likelihood of a max exponential with the given parameters on the given data. More...
 
pair< double, double > vg::fit_weibull (const vector< double > &x)
 Returns an estimate of the rate and shape parameters of a Weibull distribution. More...
 
tuple< double, double, double > vg::fit_offset_weibull (const vector< double > &x, double tolerance=1e-8)
 Returns an estimate of the rate, shape, and location (minimum value) of a 3-parameter Weibull distribution. More...
 
double vg::weibull_cdf (double x, double scale, double shape, double location=0.0)
 Return the CDF of a max exponential with the given parameters. More...
 
double vg::weibull_log_likelihood (const vector< double > &x, double scale, double shape, double location=0.0)
 Returns the log likelihood of some data generated by a Weibull distribution. More...
 
double vg::golden_section_search (const function< double(double)> &f, double x_min, double x_max, double tolerance=1e-8)
 Returns a local maximum of a function within an interval. More...
 
vector< vector< double > > vg::transpose (const vector< vector< double >> &A)
 A shitty set of linear algebra functions. More...
 
vector< vector< double > > vg::matrix_multiply (const vector< vector< double >> &A, const vector< vector< double >> &B)
 
vector< double > vg::matrix_multiply (const vector< vector< double >> &A, const vector< double > &b)
 
vector< vector< double > > vg::matrix_invert (const vector< vector< double >> &A)
 
vector< double > vg::regress (const vector< vector< double >> &X, vector< double > &y)
 Returns the coefficients of a regression (does not automatically compute constant) More...
 
real_t vg::gamma_ln (real_t x)
 
real_t vg::factorial_ln (int n)
 
real_t vg::pow_ln (real_t m, int n)
 
real_t vg::choose_ln (int n, int k)
 
real_t vg::multinomial_choose_ln (int n, vector< int > k)
 
real_t vg::poisson_prob_ln (int observed, real_t expected)
 
template<typename ProbIn >
real_t vg::multinomial_sampling_prob_ln (const vector< ProbIn > &probs, const vector< int > &obs)
 
template<typename ProbIn >
real_t vg::binomial_cmf_ln (ProbIn success_logprob, size_t trials, size_t successes)
 
template<typename ProbIn >
real_t vg::geometric_sampling_prob_ln (ProbIn success_logprob, size_t trials)
 
template<typename Iter >
bool vg::advance_split (Iter start, Iter end)
 
template<typename ProbIn >
real_t vg::multinomial_censored_sampling_prob_ln (const vector< ProbIn > &probs, const unordered_map< vector< bool >, int > &obs)
 
real_t vg::ewens_af_prob_ln (const vector< int > &a, real_t theta)
 

Detailed Description

Defines a range of statistical functions