npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
npstat::MultivariateWeightedSumsqAccumulator< Precise > Class Template Reference

#include <MultivariateWeightedSumsqAccumulator.hh>

Public Types

typedef Precise precise_type
 

Public Member Functions

template<typename Precise2 >
 MultivariateWeightedSumsqAccumulator (const unsigned long *columns, unsigned nColumns, const MultivariateWeightedSumAccumulator< Precise2 > &sums)
 
template<typename Precise2 >
 MultivariateWeightedSumsqAccumulator (const MultivariateWeightedSumAccumulator< Precise2 > &sums)
 
unsigned dim () const
 
unsigned long ncalls () const
 
unsigned long expectedNumCols () const
 
Precise weightSum () const
 
const std::vector< unsigned long > & indexMap () const
 
const std::vector< Precise > & meanVector () const
 
Precise mean (const unsigned i) const
 
Precise count () const
 
template<typename T >
void accumulate (const T *data, unsigned long len, double w)
 
void reset ()
 
const Precise & sumsq (unsigned i, unsigned j) const
 
Precise cov (unsigned i, unsigned j) const
 
Precise corr (unsigned i, unsigned j) const
 
Precise stdev (unsigned i) const
 
Matrix< Precise > covMat () const
 
Matrix< Precise > corrMat () const
 

Detailed Description

template<typename Precise = long double>
class npstat::MultivariateWeightedSumsqAccumulator< Precise >

Class for accumulating multivariate weighted sums of squares and calculating corresponding covariances. Intended for use together with MultivariateWeightedSumAccumulator. For example, to determine covariance matrix of all ntuple columns, do something along the following lines:

const AbsNtuple<T>& nt = ... // reference to your ntuple
const WeightCalculator& wcalc = ... // reference to the weight functor
MultivariateWeightedSumAccumulator sums;
nt.weightedCycleOverRows(sums, wcalc);
nt.weightedCycleOverRows(sumsqs, wcalc);
const Matrix<long double>& m = sumsqs.covMat(); // covariance matrix
MultivariateWeightedSumsqAccumulator(const unsigned long *columns, unsigned nColumns, const MultivariateWeightedSumAccumulator< Precise2 > &sums)

Constructor & Destructor Documentation

◆ MultivariateWeightedSumsqAccumulator() [1/2]

template<typename Precise = long double>
template<typename Precise2 >
npstat::MultivariateWeightedSumsqAccumulator< Precise >::MultivariateWeightedSumsqAccumulator ( const unsigned long *  columns,
unsigned  nColumns,
const MultivariateWeightedSumAccumulator< Precise2 > &  sums 
)

To calculate covariances for select columns only, use this constructor with a non-trivial column map. Statistics will be accumulated only for the columns included in the "columns" argument. This can be useful for speeding up the code, as the computational complexity of covariance matrix calculations increases as the number of columns squared.

◆ MultivariateWeightedSumsqAccumulator() [2/2]

template<typename Precise = long double>
template<typename Precise2 >
npstat::MultivariateWeightedSumsqAccumulator< Precise >::MultivariateWeightedSumsqAccumulator ( const MultivariateWeightedSumAccumulator< Precise2 > &  sums)
explicit

Constructor with a trivial column map

Member Function Documentation

◆ accumulate()

template<typename Precise = long double>
template<typename T >
void npstat::MultivariateWeightedSumsqAccumulator< Precise >::accumulate ( const T *  data,
unsigned long  len,
double  w 
)

Accumulate statistics for an array (ntuple row)

◆ corr()

template<typename Precise = long double>
Precise npstat::MultivariateWeightedSumsqAccumulator< Precise >::corr ( unsigned  i,
unsigned  j 
) const

Correlation coefficient between the given variables

◆ corrMat()

template<typename Precise = long double>
Matrix<Precise> npstat::MultivariateWeightedSumsqAccumulator< Precise >::corrMat ( ) const

Retrieve the correlation matrix

◆ count()

template<typename Precise = long double>
Precise npstat::MultivariateWeightedSumsqAccumulator< Precise >::count ( ) const

This method returns the effective number of counts which is (squared sum of weights)/(sum of squared weights)

◆ cov()

template<typename Precise = long double>
Precise npstat::MultivariateWeightedSumsqAccumulator< Precise >::cov ( unsigned  i,
unsigned  j 
) const

Covariance between the variables corresponding to the given indices (as mapped to the original indices)

◆ covMat()

template<typename Precise = long double>
Matrix<Precise> npstat::MultivariateWeightedSumsqAccumulator< Precise >::covMat ( ) const

Retrieve the covariance matrix

◆ dim()

template<typename Precise = long double>
unsigned npstat::MultivariateWeightedSumsqAccumulator< Precise >::dim ( ) const
inline

Inspect object properties

◆ meanVector()

template<typename Precise = long double>
const std::vector<Precise>& npstat::MultivariateWeightedSumsqAccumulator< Precise >::meanVector ( ) const
inline

Mean values from the sum accumulator provided in the constructor

◆ reset()

template<typename Precise = long double>
void npstat::MultivariateWeightedSumsqAccumulator< Precise >::reset ( )

Reset all accumulators and counters

◆ stdev()

template<typename Precise = long double>
Precise npstat::MultivariateWeightedSumsqAccumulator< Precise >::stdev ( unsigned  i) const

Standard deviation for the given variable

◆ sumsq()

template<typename Precise = long double>
const Precise& npstat::MultivariateWeightedSumsqAccumulator< Precise >::sumsq ( unsigned  i,
unsigned  j 
) const

Accumulated sums of squares or cross terms


The documentation for this class was generated from the following file: