KrisLibrary  1.0.0
Classes | Functions
Statistics Namespace Reference

Contains all definitions in the statistics directory. More...

Classes

struct  BernoulliDistribution
 
struct  BernoulliMAPModel
 
struct  BetaDistribution
 
struct  BoxProbabilityDistribution
 
struct  CategoricalDistribution
 
struct  CategoricalMAPModel
 
class  DataSet
 
struct  DiracDistribution
 
struct  DiracMultivariateDistribution
 
struct  DistributionCollector
 Incrementally collects samples from a univariate distribution. More...
 
class  DistributionCollectorND
 Incrementally collects samples from a multivariate distribution. More...
 
struct  GaussianDistribution
 
class  GaussianHMM
 A model of a temporal sequence consisting of k discrete states each with a gaussian emission probability. More...
 
class  GaussianHMMRegression
 
class  GaussianMixtureModel
 A model of a probability distribution consisting of k gaussians. More...
 
class  GaussianMixtureModelRaw
 A more ``raw'' model of a GMM that does not perform a cholesky decomposiition. More...
 
class  GaussianMixtureRegression
 
struct  GaussianMultivariateDistribution
 
class  GaussianRegression
 
class  HierarchicalClustering
 
class  Histogram
 1-D histogram class More...
 
class  Histogram2D
 2-D histogram class More...
 
class  Histogram3D
 3-D histogram class More...
 
class  HistogramND
 N-D histogram class. More...
 
struct  IndexHash
 
class  IntervalMap
 Division of the real numbers into interval sets. Each interval is assigned data of type Data. More...
 
class  IntervalMap2D
 
class  KMeans
 A simple clustering method to choose k clusters from a set of data. More...
 
class  LeastSquares1D
 1-D least squares y = ax+b More...
 
class  LinearModel
 A linear model of n-dimensional data. More...
 
class  LinearProcess
 
class  LinearProcessHMM
 A model of a temporal sequence consisting of k discrete states each with a gaussian emission probability depending on the prior continuous state. More...
 
class  LinearProcessHMMRegression
 
class  LinearProcessHMMState
 
class  LogisticModel
 Models the probability of a boolean outcome using a logit. More...
 
struct  MultivariateProbabilityDistribution
 
struct  OnlineLeastSquares
 Online estimation of least-squares solution to y = A x. More...
 
struct  OnlineMoments
 Online calculation of mean, covariance, min/max of vectors. More...
 
struct  StochasticLeastSquares
 Stochastic gradient descent estimation of least-squares solution to y = A x. More...
 
struct  StochasticPseudoLASSO
 Stochastic estimation of solution to y = A x via a LASSO-like procedure min_x ||b-A x||^2 + alpha*||x||_1. More...
 
struct  UniformProbabilityDistribution
 
struct  UnivariateProbabilityDistribution
 

Functions

Real Normalize (vector< Real > &w)
 
Real NormalizeProbability (Vector &w)
 
Real ExpNormalize (vector< Real > &w)
 
Real ExpNormalize (Vector &w)
 
Real logDot (const Gaussian< Real > &g, const Vector &xmean, const Matrix &xcov)
 
void AddOuterProduct (Matrix &A, const Vector &u, const Vector &v)
 
std::ostream & operator<< (std::ostream &out, const GaussianHMM &gmm)
 
std::istream & operator>> (std::istream &in, GaussianHMM &gmm)
 
void Subsample (vector< Real > &weights, vector< int > &values)
 
Real LogDotProduct (const Vector &mu1, const Matrix &K1, const Vector &mu2, const Matrix &K2)
 Computes int_x b1(x)b2(x) dx with b1(x) = N(x;mu1,K1), b2 = N(x;mu2,K2) More...
 
Real LogCosAngle (const Vector &mu1, const Matrix &K1, const Vector &mu2, const Matrix &K2)
 
Real LogCosAngle (const Gaussian< Real > &g1, const Gaussian< Real > &g2)
 
ostream & operator<< (ostream &out, const GaussianMixtureModel &gmm)
 
ostream & operator<< (ostream &out, const GaussianMixtureModelRaw &gmm)
 
istream & operator>> (istream &in, GaussianMixtureModel &gmm)
 
istream & operator>> (istream &in, GaussianMixtureModelRaw &gmm)
 
std::ostream & operator<< (std::ostream &out, const GaussianMixtureModel &gmm)
 
std::istream & operator>> (std::istream &in, GaussianMixtureModel &gmm)
 
std::ostream & operator<< (std::ostream &out, const GaussianMixtureModelRaw &gmm)
 
std::istream & operator>> (std::istream &in, GaussianMixtureModelRaw &gmm)
 
std::istream & operator>> (std::istream &in, LinearModel &model)
 
std::ostream & operator<< (std::ostream &out, const LinearModel &model)
 
std::ostream & operator<< (std::ostream &out, const LinearProcessHMM &gmm)
 
std::istream & operator>> (std::istream &in, LinearProcessHMM &gmm)
 
void MixtureCollapse (GaussianMixtureModelRaw &x, int k, bool refit)
 
ostream & operator<< (ostream &out, const LogisticModel &model)
 
istream & operator>> (istream &in, LogisticModel &model)
 
std::ostream & operator<< (std::ostream &out, const LogisticModel &model)
 
std::istream & operator>> (std::istream &in, LogisticModel &model)
 
bool LeastSquares (const Matrix &data, const Vector &outcome, Vector &coeffs, Real &offset)
 Calculate a least squares fit of the outcome given data. More...
 
bool LeastSquares (const vector< Vector > &data, int dependentVariable, Vector &coeffs)
 Calculate a least squares fit of some dependent variable. More...
 
bool LeastSquaresPickDependent (const vector< Vector > &data, int &dependentVariable, Vector &coeffs)
 Calculate a least squares fit and pick some dependent variable. More...
 
bool LeastSquares (const std::vector< Vector > &data, int dependentVariable, Vector &coeffs)
 Calculate a least squares fit of some dependent variable. More...
 
bool LeastSquaresPickDependent (const std::vector< Vector > &data, int &dependentVariable, Vector &coeffs)
 Calculate a least squares fit and pick some dependent variable. More...
 
void Sum (const vector< Vector > &data, Vector &sum)
 
void Sum (const Matrix &data, Vector &sum)
 
Real Mean (const vector< Real > &data)
 
Real Mean (const Vector &data)
 
void Mean (const vector< Vector > &data, Vector &mean)
 
void Mean (const Matrix &data, Vector &mean)
 
Real Variance (const vector< Real > &data)
 
Real Variance (const Vector &data)
 
void Variance (const vector< Vector > &data, Vector &var)
 
void Variance (const Matrix &data, Vector &var)
 
Real StdDev (const vector< Real > &data)
 
Real StdDev (const Vector &data)
 
void StdDev (const vector< Vector > &data, Vector &stddev)
 
void StdDev (const Matrix &data, Vector &stddev)
 
Real StdDev_Robust (const vector< Real > &data)
 
Real StdDev_Robust (const Vector &data)
 
void StdDev_Robust (const vector< Vector > &data, Vector &stddev)
 
void StdDev_Robust (const Matrix &data, Vector &stddev)
 
Real WeightedSum (const Vector &data, const Vector &w)
 
void WeightedSum (const Matrix &data, const Vector &w, Vector &sum)
 
Real WeightedMean (const Vector &data, const Vector &w)
 
void WeightedMean (const Matrix &data, const Vector &w, Vector &mean)
 
Real WeightedVariance (const Vector &data, const Vector &w)
 
void WeightedVariance (const Matrix &data, const Vector &w, Vector &var)
 
Real WeightedStdDev (const Vector &data, const Vector &w)
 
void WeightedStdDev (const Matrix &data, const Vector &w, Vector &stddev)
 
Real Sum (const std::vector< Real > &data)
 
Real Sum (const Vector &data)
 
void Sum (const std::vector< Vector > &data, Vector &sum)
 
Real Mean (const std::vector< Real > &data)
 
void Mean (const std::vector< Vector > &data, Vector &mean)
 
Real Variance (const std::vector< Real > &data)
 
void Variance (const std::vector< Vector > &data, Vector &var)
 
Real StdDev (const std::vector< Real > &data)
 
void StdDev (const std::vector< Vector > &data, Vector &stddev)
 
Real StdDev_Robust (const std::vector< Real > &data)
 
void StdDev_Robust (const std::vector< Vector > &data, Vector &stddev)
 

Detailed Description

Contains all definitions in the statistics directory.

Function Documentation

Real Statistics::ExpNormalize ( vector< Real > &  w)

Given input of log(p)'s, perform exponentiation and normalization in a numerically stable way. Return the sum probability of the p[i]'s

References ExpNormalize(), Math::IsFinite(), and Statistics::GaussianMixtureModel::phi.

Referenced by ExpNormalize(), Statistics::GaussianHMM::Posterior(), Statistics::LinearProcessHMM::Posterior(), Statistics::GaussianMixtureModel::TrainEM(), Statistics::GaussianHMM::Update(), and Statistics::LinearProcessHMM::Update().

bool Statistics::LeastSquares ( const std::vector< Vector > &  data,
int  dependentVariable,
Vector coeffs 
)

Calculate a least squares fit of some dependent variable.

Upon success, coeffs contains the coefficients of the independent variables, as well as the constant offset in coeffs(d) where d is the index of the dependent variable.

References LeastSquares().

bool Statistics::LeastSquares ( const Matrix data,
const Vector outcome,
Vector coeffs,
Real &  offset 
)

Calculate a least squares fit of the outcome given data.

The rows of data give the individual observations. Upon success, coeffs contains the coefficients of the independent variables, and offset contains a constant offset.

References LeastSquares().

Referenced by LeastSquares(), and LeastSquaresPickDependent().

bool Statistics::LeastSquares ( const std::vector< Vector > &  data,
int  dependentVariable,
Vector coeffs 
)

Calculate a least squares fit of some dependent variable.

Upon success, coeffs contains the coefficients of the independent variables, as well as the constant offset in coeffs(d) where d is the index of the dependent variable.

References LeastSquares().

bool Statistics::LeastSquaresPickDependent ( const std::vector< Vector > &  data,
int &  dependentVariable,
Vector coeffs 
)

Calculate a least squares fit and pick some dependent variable.

Upon success, dependentVariable contains the index of the dependent variable, coeffs contains the coefficients of the independent variables, as well as the constant offset in coeffs(d) where d is the index of the dependent variable.

References LeastSquares(), and LeastSquaresPickDependent().

Referenced by LeastSquaresPickDependent().

bool Statistics::LeastSquaresPickDependent ( const std::vector< Vector > &  data,
int &  dependentVariable,
Vector coeffs 
)

Calculate a least squares fit and pick some dependent variable.

Upon success, dependentVariable contains the index of the dependent variable, coeffs contains the coefficients of the independent variables, as well as the constant offset in coeffs(d) where d is the index of the dependent variable.

References LeastSquares(), and LeastSquaresPickDependent().

Referenced by LeastSquaresPickDependent().

Real Statistics::LogDotProduct ( const Vector mu1,
const Matrix K1,
const Vector mu2,
const Matrix K2 
)

Computes int_x b1(x)b2(x) dx with b1(x) = N(x;mu1,K1), b2 = N(x;mu2,K2)

Method considers joint distribution of variables X1 ~ N(mu1,K1), X2 ~ N(mu2,K2), Y=X1-X2, X1 independent of X2: [X1;X2;Y] ~ N([mu1;mu2;mu1-mu2],[K1,0,K1; 0,K2,-K2; K1,-K2,K1+K2]) and then considers the probability that Y=0. Y ~= N(mu1-mu2,K1+K2) => N(0;mu1-mu2,K1+K2) = int_x b1(x)b2(x) dx

References Math::Gaussian< T >::L, LogDotProduct(), Math::Gaussian< T >::logProbability(), Math::Gaussian< T >::mu, Normalize(), Statistics::GaussianMixtureModel::phi, Statistics::GaussianMixtureModelRaw::phi, and Math::Gaussian< T >::setCovariance().

Referenced by LogDotProduct().

Real Statistics::Normalize ( vector< Real > &  w)

Given input of nonnegative p's, perform normalization in a numerically stable way. Returns the sum of the p's. Specifically, if all p's are 0, then it returns a uniform distribution. If any p is infinite, then all non-infinite p's are set to 0 while the remaining weight is distributed evenly among all infinite p's

References Math::IsInf(), and Normalize().

Referenced by LogDotProduct(), Normalize(), Statistics::LinearProcessHMM::Posterior(), and Statistics::GaussianMixtureModel::TrainEM().