casacore
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
casacore::StatisticsUtilities< AccumType > Class Template Reference

Various statistics related methods for the statistics framework. More...

#include <StatisticsUtilities.h>

Classes

struct  BinDesc
 description of a regularly spaced bins with the first bin having lower limit of minLimit and having nBins equally spaced bins of width binWidth, so that the upper limit of the last bin is given by minLimit + nBins*binWidth More...
 

Public Member Functions

 ~StatisticsUtilities ()
 
template<>
Int getInt (const casacore::Complex &)
 The Complex and DComplex versions are used solely to permit compilation. More...
 
template<>
Int getInt (const casacore::DComplex &)
 

Static Public Member Functions

static void accumulate (Double &npts, AccumType &sum, AccumType &mean, const AccumType &datum)
 accumulate values. More...
 
static void waccumulate (Double &npts, AccumType &sumweights, AccumType &wsum, AccumType &wmean, const AccumType &datum, const AccumType &weight)
 in order to optimize performance, no checking is done for the weight == 0 case callers should ensure that the weigth is not zero before calling this method, and shouldn't call this method if the weight is 0. More...
 
static void accumulate (Double &npts, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, const AccumType &datum)
 
static void waccumulate (Double &npts, AccumType &sumweights, AccumType &wsum, AccumType &wmean, AccumType &wnvariance, AccumType &wsumsq, const AccumType &datum, const AccumType &weight)
 wsumsq is the weighted sum of squares, sum(w_i*x_i*x_i) More...
 
template<class LocationType >
static void accumulate (Double &npts, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const LocationType &location)
 The assignment operator of class LocationType should use copy, not reference, semantics. More...
 
template<class LocationType , class DataType >
static void accumulate (Double &npts, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, DataType &datamin, DataType &datamax, LocationType &minpos, LocationType &maxpos, const DataType &datum, const LocationType &location)
 
template<class LocationType >
static void waccumulate (Double &npts, AccumType &sumofweights, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const AccumType &weight, const LocationType &location)
 
template<class LocationType >
static Bool doMax (AccumType &datamax, LocationType &maxpos, Bool isFirst, const AccumType &datum, const LocationType &location)
 return True if the max or min was updated, False otherwise. More...
 
template<class LocationType >
static Bool doMin (AccumType &datamin, LocationType &minpos, Bool isFirst, const AccumType &datum, const LocationType &location)
 
static void accumulateSym (Double &npts, AccumType &nvariance, AccumType &sumsq, const AccumType &datum, const AccumType &center)
 These versions are for symmetric accumulation about a specified center point. More...
 
static void waccumulateSym (Double &npts, AccumType &sumweights, AccumType &wnvariance, AccumType &wsumsq, const AccumType &datum, const AccumType &weight, const AccumType &center)
 wsumsq is the weighted sum of squares, sum(w_i*x_i*x_i) More...
 
template<class LocationType >
static void accumulateSym (Double &npts, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const LocationType &location, const AccumType &center)
 maxpos and minpos refer to actual, not virtually created, data only. More...
 
template<class LocationType >
static void waccumulateSym (Double &npts, AccumType &sumofweights, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const AccumType &weight, const LocationType &location, const AccumType &center)
 
static Int getInt (const AccumType &v)
 This does the obvious conversions. More...
 
static Bool includeDatum (const AccumType &datum, typename DataRanges::const_iterator beginRange, typename DataRanges::const_iterator endRange, Bool isInclude)
 
static StatsData< AccumType > combine (const vector< StatsData< AccumType > > &stats)
 use two statistics sets to get the statistics set that would result in combining the two data sets used to produce the individual statistics sets. More...
 

Private Member Functions

 StatisticsUtilities ()
 

Static Private Attributes

static const AccumType TWO
 

Detailed Description

template<class AccumType>
class casacore::StatisticsUtilities< AccumType >

Various statistics related methods for the statistics framework.

Definition at line 42 of file StatisticsUtilities.h.

Constructor & Destructor Documentation

◆ ~StatisticsUtilities()

template<class AccumType >
casacore::StatisticsUtilities< AccumType >::~StatisticsUtilities ( )
inline

◆ StatisticsUtilities()

template<class AccumType >
casacore::StatisticsUtilities< AccumType >::StatisticsUtilities ( )
inlineprivate

Definition at line 215 of file StatisticsUtilities.h.

Member Function Documentation

◆ accumulate() [1/4]

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::accumulate ( Double npts,
AccumType &  sum,
AccumType &  mean,
const AccumType &  datum 
)
inlinestatic

accumulate values.

It is the responsibility of the caller to keep track of the accumulated values after each call. This class does not since it has no state. The accumulation derivation for mean and variance can be found at www.itl.nist.gov/div898/software/dataplot/refman2/ch2/weighvar.pdf nvariance is an accumulated value. It is related to the variance via variance = nvariance/npts or nvariance/(npts-1) depending on your preferred definition in the non-weighted case and wvariance = wnvariance/sumofweights or wnvariance/(sumofweights-1) in the weighted case It's basic definition is nvariance = sum((x_i - mean)**2), wnvariance = sum((weight_i*(x_i - mean)**2) npts is a Double rather than an Int64 because of compilation issues when T is a Complex

Referenced by casacore::StatisticsUtilities< AccumType >::~StatisticsUtilities().

◆ accumulate() [2/4]

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::accumulate ( Double npts,
AccumType &  sum,
AccumType &  mean,
AccumType &  nvariance,
AccumType &  sumsq,
const AccumType &  datum 
)
inlinestatic

◆ accumulate() [3/4]

template<class AccumType >
template<class LocationType >
static void casacore::StatisticsUtilities< AccumType >::accumulate ( Double npts,
AccumType &  sum,
AccumType &  mean,
AccumType &  nvariance,
AccumType &  sumsq,
AccumType &  datamin,
AccumType &  datamax,
LocationType minpos,
LocationType maxpos,
const AccumType &  datum,
const LocationType location 
)
inlinestatic

The assignment operator of class LocationType should use copy, not reference, semantics.

◆ accumulate() [4/4]

template<class AccumType >
template<class LocationType , class DataType >
static void casacore::StatisticsUtilities< AccumType >::accumulate ( Double npts,
AccumType &  sum,
AccumType &  mean,
AccumType &  nvariance,
AccumType &  sumsq,
DataType &  datamin,
DataType &  datamax,
LocationType minpos,
LocationType maxpos,
const DataType &  datum,
const LocationType location 
)
inlinestatic

◆ accumulateSym() [1/2]

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::accumulateSym ( Double npts,
AccumType &  nvariance,
AccumType &  sumsq,
const AccumType &  datum,
const AccumType &  center 
)
inlinestatic

These versions are for symmetric accumulation about a specified center point.

The actual point is accumulated, as is a "virtual" point that is symmetric about the specified center. Of course, the trivial relationship that the mean is the specified center is used to simplify things.

Referenced by casacore::StatisticsUtilities< AccumType >::~StatisticsUtilities().

◆ accumulateSym() [2/2]

template<class AccumType >
template<class LocationType >
static void casacore::StatisticsUtilities< AccumType >::accumulateSym ( Double npts,
AccumType &  nvariance,
AccumType &  sumsq,
AccumType &  datamin,
AccumType &  datamax,
LocationType minpos,
LocationType maxpos,
const AccumType &  datum,
const LocationType location,
const AccumType &  center 
)
inlinestatic

maxpos and minpos refer to actual, not virtually created, data only.

◆ combine()

template<class AccumType >
static StatsData<AccumType> casacore::StatisticsUtilities< AccumType >::combine ( const vector< StatsData< AccumType > > &  stats)
static

use two statistics sets to get the statistics set that would result in combining the two data sets used to produce the individual statistics sets.

The quantile related stats are not considered, since it is not in general possible to determine the resultant quantiles from the information provided; only the aggregate statistics make sense.

Referenced by casacore::StatisticsUtilities< AccumType >::getInt().

◆ doMax()

template<class AccumType >
template<class LocationType >
static Bool casacore::StatisticsUtilities< AccumType >::doMax ( AccumType &  datamax,
LocationType maxpos,
Bool  isFirst,
const AccumType &  datum,
const LocationType location 
)
inlinestatic

return True if the max or min was updated, False otherwise.

Referenced by casacore::StatisticsUtilities< AccumType >::~StatisticsUtilities().

◆ doMin()

template<class AccumType >
template<class LocationType >
static Bool casacore::StatisticsUtilities< AccumType >::doMin ( AccumType &  datamin,
LocationType minpos,
Bool  isFirst,
const AccumType &  datum,
const LocationType location 
)
inlinestatic

◆ getInt() [1/3]

template<class AccumType >
static Int casacore::StatisticsUtilities< AccumType >::getInt ( const AccumType &  v)
inlinestatic

This does the obvious conversions.

The Complex and DComplex versions (implemented after the class definition) are used solely to permit compilation. In general, these versions should never actually be called

Definition at line 192 of file StatisticsUtilities.h.

References casacore::StatisticsUtilities< AccumType >::combine(), and casacore::StatisticsUtilities< AccumType >::includeDatum().

◆ getInt() [2/3]

template<>
Int casacore::StatisticsUtilities< casacore::Complex >::getInt ( const casacore::Complex &  )
inline

The Complex and DComplex versions are used solely to permit compilation.

In general, these versions should never actually be called

Definition at line 223 of file StatisticsUtilities.h.

References ThrowCc.

◆ getInt() [3/3]

template<>
Int casacore::StatisticsUtilities< casacore::DComplex >::getInt ( const casacore::DComplex &  )
inline

Definition at line 228 of file StatisticsUtilities.h.

References ThrowCc.

◆ includeDatum()

template<class AccumType >
static Bool casacore::StatisticsUtilities< AccumType >::includeDatum ( const AccumType &  datum,
typename DataRanges::const_iterator  beginRange,
typename DataRanges::const_iterator  endRange,
Bool  isInclude 
)
inlinestatic

◆ waccumulate() [1/3]

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::waccumulate ( Double npts,
AccumType &  sumweights,
AccumType &  wsum,
AccumType &  wmean,
const AccumType &  datum,
const AccumType &  weight 
)
inlinestatic

in order to optimize performance, no checking is done for the weight == 0 case callers should ensure that the weigth is not zero before calling this method, and shouldn't call this method if the weight is 0.

Expect a segfault because of division by zero if sumweights and weight are both zero.

Referenced by casacore::StatisticsUtilities< AccumType >::~StatisticsUtilities().

◆ waccumulate() [2/3]

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::waccumulate ( Double npts,
AccumType &  sumweights,
AccumType &  wsum,
AccumType &  wmean,
AccumType &  wnvariance,
AccumType &  wsumsq,
const AccumType &  datum,
const AccumType &  weight 
)
inlinestatic

wsumsq is the weighted sum of squares, sum(w_i*x_i*x_i)

◆ waccumulate() [3/3]

template<class AccumType >
template<class LocationType >
static void casacore::StatisticsUtilities< AccumType >::waccumulate ( Double npts,
AccumType &  sumofweights,
AccumType &  sum,
AccumType &  mean,
AccumType &  nvariance,
AccumType &  sumsq,
AccumType &  datamin,
AccumType &  datamax,
LocationType minpos,
LocationType maxpos,
const AccumType &  datum,
const AccumType &  weight,
const LocationType location 
)
inlinestatic

◆ waccumulateSym() [1/2]

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::waccumulateSym ( Double npts,
AccumType &  sumweights,
AccumType &  wnvariance,
AccumType &  wsumsq,
const AccumType &  datum,
const AccumType &  weight,
const AccumType &  center 
)
inlinestatic

wsumsq is the weighted sum of squares, sum(w_i*x_i*x_i)

Referenced by casacore::StatisticsUtilities< AccumType >::~StatisticsUtilities().

◆ waccumulateSym() [2/2]

template<class AccumType >
template<class LocationType >
static void casacore::StatisticsUtilities< AccumType >::waccumulateSym ( Double npts,
AccumType &  sumofweights,
AccumType &  nvariance,
AccumType &  sumsq,
AccumType &  datamin,
AccumType &  datamax,
LocationType minpos,
LocationType maxpos,
const AccumType &  datum,
const AccumType &  weight,
const LocationType location,
const AccumType &  center 
)
inlinestatic

Member Data Documentation

◆ TWO

template<class AccumType >
const AccumType casacore::StatisticsUtilities< AccumType >::TWO
staticprivate

Definition at line 213 of file StatisticsUtilities.h.


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