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

#include <WeightedSampleAccumulator.hh>

Public Types

typedef Numeric value_type
 
typedef Precise precise_type
 

Public Member Functions

double maxWeight () const
 
unsigned long ncalls () const
 
unsigned long nfills () const
 
double count () const
 
Numeric min () const
 
Numeric max () const
 
Precise mean () const
 
Precise stdev () const
 
Precise meanUncertainty () const
 
Numeric median () const
 
double cdf (Numeric value) const
 
double weightBelow (Numeric value) const
 
Numeric quantile (double x) const
 
Numeric location () const
 
Numeric rangeDown () const
 
Numeric rangeUp () const
 
Numeric sigmaRange () const
 
Precise noThrowMean (const Precise &valueIfNoData) const
 
Precise noThrowStdev (const Precise &valueIfNoData) const
 
Precise noThrowMeanUncertainty (const Precise &valueIfNoData) const
 
double averageWeight () const
 
double sumOfWeights () const
 
double sumOfSquaredWeights () const
 
const std::pair< Numeric, double > * data () const
 
bool operator== (const WeightedSampleAccumulator &r) const
 
bool operator!= (const WeightedSampleAccumulator &r) const
 
void accumulate (const Numeric &value, double weight)
 
void accumulate (const WeightedSampleAccumulator &acc)
 
template<typename Pair >
void accumulate (const Pair *values, unsigned long n)
 
template<typename Pair >
void accumulate (const Pair &pair)
 
template<typename Pair >
WeightedSampleAccumulatoroperator+= (const Pair &pair)
 
WeightedSampleAccumulatoroperator+= (const WeightedSampleAccumulator &r)
 
template<typename Num2 >
WeightedSampleAccumulatoroperator*= (const Num2 &r)
 
template<typename Num2 >
WeightedSampleAccumulatoroperator/= (const Num2 &r)
 
WeightedSampleAccumulator operator+ (const WeightedSampleAccumulator &r) const
 
template<typename Num2 >
WeightedSampleAccumulator operator* (const Num2 &r) const
 
template<typename Num2 >
WeightedSampleAccumulator operator/ (const Num2 &r) const
 
WeightedSampleAccumulatorscaleWeights (double r)
 
void reset ()
 
void reserve (const unsigned long n)
 
gs::ClassId classId () const
 
bool write (std::ostream &of) const
 

Static Public Member Functions

static const char * classname ()
 
static unsigned version ()
 
static void restore (const gs::ClassId &id, std::istream &in, WeightedSampleAccumulator *acc)
 

Detailed Description

template<typename Numeric, typename Precise = typename PreciseType<Numeric>::type>
class npstat::WeightedSampleAccumulator< Numeric, Precise >

Accumulator of weighted points for the purpose of calculating statistical summaries in a numerically stable manner

Member Function Documentation

◆ accumulate() [1/3]

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
void npstat::WeightedSampleAccumulator< Numeric, Precise >::accumulate ( const Numeric &  value,
double  weight 
)

Accumulate the sample. Weights must be non-negative. Run-time error will be generated for negative weights.

◆ accumulate() [2/3]

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
template<typename Pair >
void npstat::WeightedSampleAccumulator< Numeric, Precise >::accumulate ( const Pair *  values,
unsigned long  n 
)

In this method, it is assumed that the first element of the pair is the value of type Numeric and the second is the weight which can be automatically converted to double

◆ accumulate() [3/3]

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
void npstat::WeightedSampleAccumulator< Numeric, Precise >::accumulate ( const WeightedSampleAccumulator< Numeric, Precise > &  acc)

Accumulate the sample from another accumulator

◆ averageWeight()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
double npstat::WeightedSampleAccumulator< Numeric, Precise >::averageWeight ( ) const

Average weight (fills with 0 weight are ignored)

◆ cdf()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
double npstat::WeightedSampleAccumulator< Numeric, Precise >::cdf ( Numeric  value) const

Empirical cumulative distribuition function

◆ classId()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
gs::ClassId npstat::WeightedSampleAccumulator< Numeric, Precise >::classId ( ) const
inline

Method related to "geners" I/O

◆ count()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
double npstat::WeightedSampleAccumulator< Numeric, Precise >::count ( ) const

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

◆ data()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
const std::pair<Numeric,double>* npstat::WeightedSampleAccumulator< Numeric, Precise >::data ( ) const
inline

Note that the result returned by this method can be invalidated by a call to any non-const method. The data will include only the points with non-zero weights.

◆ location()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Numeric npstat::WeightedSampleAccumulator< Numeric, Precise >::location ( ) const
inline

Standard plotting accessor

◆ max()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Numeric npstat::WeightedSampleAccumulator< Numeric, Precise >::max ( ) const

Maximum value in the accumulated sample

◆ maxWeight()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
double npstat::WeightedSampleAccumulator< Numeric, Precise >::maxWeight ( ) const
inline

Maximum weight among those accumulate so far

◆ mean()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Precise npstat::WeightedSampleAccumulator< Numeric, Precise >::mean ( ) const

Accumulated sample average

◆ meanUncertainty()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Precise npstat::WeightedSampleAccumulator< Numeric, Precise >::meanUncertainty ( ) const

Uncertainty of the population mean

◆ median()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Numeric npstat::WeightedSampleAccumulator< Numeric, Precise >::median ( ) const

Accumulated sample median

◆ min()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Numeric npstat::WeightedSampleAccumulator< Numeric, Precise >::min ( ) const

Minimum value in the accumulated sample

◆ ncalls()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
unsigned long npstat::WeightedSampleAccumulator< Numeric, Precise >::ncalls ( ) const
inline

This method returns the total number of times the "accumulate" method was called on individual points since the last reset (or since the object was created)

◆ nfills()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
unsigned long npstat::WeightedSampleAccumulator< Numeric, Precise >::nfills ( ) const
inline

This method returns the number of times the "accumulate" method was called with a positive weight

◆ noThrowMean()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Precise npstat::WeightedSampleAccumulator< Numeric, Precise >::noThrowMean ( const Precise &  valueIfNoData) const

Accumulated sample average. Will not throw an exception if no data is accumulated. Instead, the provided function argument will be returned.

◆ noThrowMeanUncertainty()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Precise npstat::WeightedSampleAccumulator< Numeric, Precise >::noThrowMeanUncertainty ( const Precise &  valueIfNoData) const

Uncertainty of the mean. Will not throw an exception if no data is accumulated. Instead, the provided function argument will be returned.

◆ noThrowStdev()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Precise npstat::WeightedSampleAccumulator< Numeric, Precise >::noThrowStdev ( const Precise &  valueIfNoData) const

Standard deviation estimate. Will not throw an exception if no data is accumulated. Instead, the provided function argument will be returned.

◆ operator!=()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
bool npstat::WeightedSampleAccumulator< Numeric, Precise >::operator!= ( const WeightedSampleAccumulator< Numeric, Precise > &  r) const

Logical negation of operator==

◆ operator*=()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
template<typename Num2 >
WeightedSampleAccumulator& npstat::WeightedSampleAccumulator< Numeric, Precise >::operator*= ( const Num2 &  r)

The effect of "operator*=" is the same as if all values were multiplied by "r" for each "accumulate" call

◆ operator+=()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
WeightedSampleAccumulator& npstat::WeightedSampleAccumulator< Numeric, Precise >::operator+= ( const WeightedSampleAccumulator< Numeric, Precise > &  r)
inline

Add the sample from another accumulator

◆ operator/=()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
template<typename Num2 >
WeightedSampleAccumulator& npstat::WeightedSampleAccumulator< Numeric, Precise >::operator/= ( const Num2 &  r)

The effect of "operator/=" is the same as if all values were divided by "r" for each "accumulate" call

◆ operator==()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
bool npstat::WeightedSampleAccumulator< Numeric, Precise >::operator== ( const WeightedSampleAccumulator< Numeric, Precise > &  r) const

Comparison for equality

◆ quantile()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Numeric npstat::WeightedSampleAccumulator< Numeric, Precise >::quantile ( double  x) const

Empirical quantile function

◆ reserve()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
void npstat::WeightedSampleAccumulator< Numeric, Precise >::reserve ( const unsigned long  n)
inline

Reserve memory for points to be accumulated in the future

◆ reset()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
void npstat::WeightedSampleAccumulator< Numeric, Precise >::reset ( )

Clear all accumulated data

◆ scaleWeights()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
WeightedSampleAccumulator& npstat::WeightedSampleAccumulator< Numeric, Precise >::scaleWeights ( double  r)

Scale the weights. The effect is the same as if all weights were multiplied by "r" for each "accumulate" call. Note that r can not be negative for this method.

◆ sigmaRange()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Numeric npstat::WeightedSampleAccumulator< Numeric, Precise >::sigmaRange ( ) const
inline

Robust scale corresponding to the standard deviation for points distributed according to the Gaussian distribution

◆ stdev()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
Precise npstat::WeightedSampleAccumulator< Numeric, Precise >::stdev ( ) const

Estimate of the population standard deviation

◆ sumOfSquaredWeights()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
double npstat::WeightedSampleAccumulator< Numeric, Precise >::sumOfSquaredWeights ( ) const

Sum of squared weights accumulated so far

◆ sumOfWeights()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
double npstat::WeightedSampleAccumulator< Numeric, Precise >::sumOfWeights ( ) const

Sum of weights accumulated so far

◆ weightBelow()

template<typename Numeric , typename Precise = typename PreciseType<Numeric>::type>
double npstat::WeightedSampleAccumulator< Numeric, Precise >::weightBelow ( Numeric  value) const

Sum of weights below the given coordinate


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