casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public 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>

Public Member Functions

 StatisticsUtilities ()=delete
 
 ~StatisticsUtilities ()
 

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 void convertToAbsDevMedArray (DataArray &myArray, AccumType median)
 convert in place by taking the absolute value of the difference of the std::vector and the median More...
 
static Bool includeDatum (const AccumType &datum, typename DataRanges::const_iterator beginRange, typename DataRanges::const_iterator endRange, Bool isInclude)
 
static std::map< uInt64,
AccumType > 
indicesToValues (std::vector< AccumType > &myArray, const std::set< uInt64 > &indices)
 The array can be changed by partially sorting it up to the largest index. More...
 
static void mergeResults (std::vector< BinCountArray > &bins, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const PtrHolder< std::vector< BinCountArray >> &tBins, const PtrHolder< std::vector< CountedPtr< AccumType >>> &tSameVal, const PtrHolder< std::vector< Bool >> &tAllSame, uInt nThreadsMax)
 
static StatsData< AccumType > combine (const std::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...
 
template<class DataIterator , class MaskIterator , class WeightsIterator >
static uInt nThreadsMax (const StatsDataProvider< CASA_STATP > *const dataProvider)
 
static uInt threadIdx ()
 

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 46 of file StatisticsUtilities.h.

Constructor & Destructor Documentation

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

Definition at line 51 of file StatisticsUtilities.h.

Member Function Documentation

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 Its 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

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::accumulate ( Double npts,
AccumType &  sum,
AccumType &  mean,
AccumType &  nvariance,
AccumType &  sumsq,
const AccumType &  datum 
)
inlinestatic
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.

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
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

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.

template<class AccumType >
static StatsData<AccumType> casacore::StatisticsUtilities< AccumType >::combine ( const std::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.

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::convertToAbsDevMedArray ( DataArray myArray,
AccumType  median 
)
inlinestatic

convert in place by taking the absolute value of the difference of the std::vector and the median

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.

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
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
template<class AccumType >
static std::map<uInt64, AccumType> casacore::StatisticsUtilities< AccumType >::indicesToValues ( std::vector< AccumType > &  myArray,
const std::set< uInt64 > &  indices 
)
static

The array can be changed by partially sorting it up to the largest index.

Return a map of index to value in the sorted array.

template<class AccumType >
static void casacore::StatisticsUtilities< AccumType >::mergeResults ( std::vector< BinCountArray > &  bins,
std::vector< CountedPtr< AccumType > > &  sameVal,
std::vector< Bool > &  allSame,
const PtrHolder< std::vector< BinCountArray >> &  tBins,
const PtrHolder< std::vector< CountedPtr< AccumType >>> &  tSameVal,
const PtrHolder< std::vector< Bool >> &  tAllSame,
uInt  nThreadsMax 
)
static
template<class AccumType >
template<class DataIterator , class MaskIterator , class WeightsIterator >
static uInt casacore::StatisticsUtilities< AccumType >::nThreadsMax ( const StatsDataProvider< CASA_STATP > *const  dataProvider)
static
template<class AccumType >
static uInt casacore::StatisticsUtilities< AccumType >::threadIdx ( )
static
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.

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)

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
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)

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

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

Definition at line 219 of file StatisticsUtilities.h.


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