26#ifndef SCIMATH_CLASSICALSTATISTICSS_H 
   27#define SCIMATH_CLASSICALSTATISTICSS_H 
   29#include <casacore/casa/aips.h> 
   31#include <casacore/scimath/StatsFramework/StatisticsAlgorithm.h> 
   33#include <casacore/scimath/StatsFramework/ClassicalQuantileComputer.h> 
   34#include <casacore/scimath/StatsFramework/StatisticsTypes.h> 
   35#include <casacore/scimath/StatsFramework/StatisticsUtilities.h> 
   58    class AccumType, 
class DataIterator, 
class MaskIterator=
const Bool*,
 
   59    class WeightsIterator=DataIterator
 
  133        std::shared_ptr<uInt64> knownNpts=
nullptr,
 
  134        std::shared_ptr<AccumType> knownMin=
nullptr,
 
  135        std::shared_ptr<AccumType> knownMax=
nullptr,
 
  136        uInt binningThreshholdSizeBytes=4096*4096,
 
  148        std::map<Double, AccumType>& quantiles,
 
  149        const std::set<Double>& fractions, std::shared_ptr<uInt64> knownNpts=
nullptr,
 
  150        std::shared_ptr<AccumType> knownMin=
nullptr,
 
  151        std::shared_ptr<AccumType> knownMax=
nullptr,
 
  152        uInt binningThreshholdSizeBytes=4096*4096,
 
  158        std::shared_ptr<uInt64> knownNpts=
nullptr,
 
  159        std::shared_ptr<AccumType> knownMin=
nullptr,
 
  160        std::shared_ptr<AccumType> knownMax=
nullptr,
 
  161        uInt binningThreshholdSizeBytes=4096*4096,
 
  168        const std::set<Double>& fractions,
 
  169        std::shared_ptr<uInt64> knownNpts=
nullptr,
 
  170        std::shared_ptr<AccumType> knownMin=
nullptr,
 
  171        std::shared_ptr<AccumType> knownMax=
nullptr,
 
  172        uInt binningThreshholdSizeBytes=4096*4096,
 
  183    virtual void getMinMax(AccumType& mymin, AccumType& mymax);
 
  186        uInt64& npts, AccumType& mymin, AccumType& mymax
 
  249        const MaskIterator& maskBegin, 
uInt maskStride
 
  254        const MaskIterator& maskBegin, 
uInt maskStride,
 
  259        uInt64& npts, 
const DataIterator& dataBegin,
 
  260        const WeightsIterator& weightsBegin, 
uInt64 nr, 
uInt dataStride
 
  264        uInt64& npts, 
const DataIterator& dataBegin,
 
  265        const WeightsIterator& weightsBegin, 
uInt64 nr, 
uInt dataStride,
 
  270        uInt64& npts, 
const DataIterator& dataBegin,
 
  271        const WeightsIterator& weightsBegin, 
uInt64 nr, 
uInt dataStride,
 
  272        const MaskIterator& maskBegin, 
uInt maskStride,
 
  277        uInt64& npts, 
const DataIterator& dataBegin,
 
  278        const WeightsIterator& weightBegin, 
uInt64 nr, 
uInt dataStride,
 
  279        const MaskIterator& maskBegin, 
uInt maskStride
 
  317        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  318        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride
 
  322        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  323        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  328        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  329        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  330        const MaskIterator& maskBegin, 
uInt maskStride
 
  334        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  335        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  336        const MaskIterator& maskBegin, 
uInt maskStride,
 
  341        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  342        const DataIterator& dataBegin, 
const WeightsIterator& weightsBegin,
 
  347        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  348        const DataIterator& dataBegin, 
const WeightsIterator& weightsBegin,
 
  353        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  354        const DataIterator& dataBegin, 
const WeightsIterator& weightsBegin,
 
  355        uInt64 nr, 
uInt dataStride, 
const MaskIterator& maskBegin,
 
  360        std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
 
  361        const DataIterator& dataBegin, 
const WeightsIterator& weightBegin,
 
  362        uInt64 nr, 
uInt dataStride, 
const MaskIterator& maskBegin,
 
  370        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  371        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin, 
uInt64 nr,
 
  376        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  377        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin, 
uInt64 nr,
 
  382        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  383        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin, 
uInt64 nr,
 
  384        uInt dataStride, 
const MaskIterator& maskBegin, 
uInt maskStride
 
  388        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  389        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin, 
uInt64 nr,
 
  390        uInt dataStride, 
const MaskIterator& maskBegin, 
uInt maskStride,
 
  395        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  396        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin,
 
  397        const WeightsIterator& weightsBegin, 
uInt64 nr, 
uInt dataStride
 
  401        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  402        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin,
 
  403        const WeightsIterator& weightsBegin, 
uInt64 nr, 
uInt dataStride,
 
  408        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  409        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin,
 
  410        const WeightsIterator& weightsBegin, 
uInt64 nr, 
uInt dataStride,
 
  411        const MaskIterator& maskBegin, 
uInt maskStride,
 
  416        uInt64& npts, std::shared_ptr<AccumType>& mymin,
 
  417        std::shared_ptr<AccumType>& mymax, 
const DataIterator& dataBegin,
 
  418        const WeightsIterator& weightBegin, 
uInt64 nr, 
uInt dataStride,
 
  419        const MaskIterator& maskBegin, 
uInt maskStride
 
  423    std::shared_ptr<StatisticsAlgorithmQuantileComputer<CASA_STATP>>
 
  432        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride
 
  438        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  444        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  445        const MaskIterator& maskBegin, 
uInt maskStride
 
  450        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  451        const MaskIterator& maskBegin, 
uInt maskStride,
 
  464        const DataIterator& dataBegin, 
const WeightsIterator& weightsBegin,
 
  470        const DataIterator& dataBegin, 
const WeightsIterator& weightsBegin,
 
  476        const DataIterator& dataBegin, 
const WeightsIterator& weightBegin,
 
  477        uInt64 nr, 
uInt dataStride, 
const MaskIterator& maskBegin,
 
  483        const DataIterator& dataBegin, 
const WeightsIterator& weightBegin,
 
  484        uInt64 nr, 
uInt dataStride, 
const MaskIterator& maskBegin,
 
  493    std::shared_ptr<ClassicalQuantileComputer<CASA_STATP>> 
_qComputer{};
 
  496        std::shared_ptr<AccumType>& mymax, std::shared_ptr<AccumType>& mymin,
 
  497        DataIterator dataIter, MaskIterator maskIter,
 
  502        uInt64& npts, std::shared_ptr<AccumType>& mymax,
 
  503        std::shared_ptr<AccumType>& mymin, DataIterator dataIter,
 
  504        MaskIterator maskIter, WeightsIterator weightsIter, 
uInt64 dataCount,
 
  509        uInt64& npts, DataIterator dataIter, MaskIterator maskIter,
 
  515        DataIterator dataIter, MaskIterator maskIter,
 
  529        uInt64& mynpts, AccumType& mymin, AccumType& mymax,
 
  530        std::shared_ptr<uInt64> knownNpts, std::shared_ptr<AccumType> knownMin,
 
  531        std::shared_ptr<AccumType> knownMax
 
 
  538#ifndef CASACORE_NO_AUTO_TEMPLATES 
  539#include <casacore/scimath/StatsFramework/ClassicalStatistics.tcc> 
This class is used internally by ClassicalStatistics objects.
 
Class to calculate statistics in a "classical" sense, ie using accumulators with no special filtering...
 
virtual AccumType getMedianAndQuantiles(std::map< Double, AccumType > &quantiles, const std::set< Double > &fractions, std::shared_ptr< uInt64 > knownNpts=nullptr, std::shared_ptr< AccumType > knownMin=nullptr, std::shared_ptr< AccumType > knownMax=nullptr, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt nBins=10000)
If one needs to compute both the median and quantile values, it is better to call getMedianAndQuantil...
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void reset()
reset object to initial state.
 
virtual const StatsData< AccumType > & _getStatsData() const
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
scan through the data set to determine the number of good (unmasked, weight > 0, within range) points...
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
 
void _computeMinMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymax, std::shared_ptr< AccumType > &mymin, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const ChunkType &chunk)
 
void _accumulate(StatsData< AccumType > &stats, const AccumType &datum, const LocationType &location)
 
virtual void _unweightedStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude)
no weights, no mask
 
virtual AccumType getMedian(std::shared_ptr< uInt64 > knownNpts=nullptr, std::shared_ptr< AccumType > knownMin=nullptr, std::shared_ptr< AccumType > knownMax=nullptr, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt nBins=10000)
In the following group of methods, if the size of the composite dataset is smaller than binningThresh...
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
 
virtual void _unweightedStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride)
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
 
typename StatisticsDataset< CASA_STATP >::ChunkData ChunkType
 
virtual std::map< Double, AccumType > getQuantiles(const std::set< Double > &fractions, std::shared_ptr< uInt64 > knownNpts=nullptr, std::shared_ptr< AccumType > knownMin=nullptr, std::shared_ptr< AccumType > knownMax=nullptr, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt nBins=10000)
Get the specified quantiles.
 
virtual AccumType _getStatistic(StatisticsData::STATS stat)
 
ClassicalStatistics & operator=(const ClassicalStatistics &other)
copy semantics
 
virtual StatsData< AccumType > _getInitialStats() const
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
 
virtual std::pair< Int64, Int64 > getStatisticIndex(StatisticsData::STATS stat)
see base class description
 
virtual uInt64 getNPts()
scan the dataset(s) that have been added, and find the number of good points.
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
 
virtual void _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride)
has weights, but no mask, no ranges
 
void setQuantileComputer(std::shared_ptr< ClassicalQuantileComputer< CASA_STATP > > qc)
Allow derived objects to set the quantile computer object.
 
virtual void _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude)
 
virtual void _updateDataProviderMaxMin(const StatsData< AccumType > &threadStats)
 
std::shared_ptr< StatisticsAlgorithmQuantileComputer< CASA_STATP > > _getQuantileComputer()
 
void _accumulate(StatsData< AccumType > &stats, const AccumType &datum, const AccumType &weight, const LocationType &location)
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _unweightedStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude)
 
virtual ~ClassicalStatistics()
 
virtual void _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride)
 
virtual void setDataProvider(StatsDataProvider< CASA_STATP > *dataProvider)
An exception will be thrown if setCalculateAsAdded(True) has been called.
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude)
 
virtual void _unweightedStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, uInt64 nr, uInt dataStride)
no weights, no mask, no ranges
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
 
void _doMinMax(AccumType &vmin, AccumType &vmax)
scan dataset(s) to find min and max
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
 
ClassicalStatistics(const ClassicalStatistics &cs)
copy semantics
 
std::shared_ptr< ClassicalQuantileComputer< CASA_STATP > > _qComputer
 
virtual StatsData< AccumType > _getStatistics()
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
Sometimes we want the min, max, and npts all in one scan.
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
 
virtual StatisticsAlgorithm< CASA_STATP > * clone() const
Clone this instance.
 
virtual void setStatsToCalculate(std::set< StatisticsData::STATS > &stats)
Provide guidance to algorithms by specifying a priori which statistics the caller would like calculat...
 
virtual void getMinMaxNpts(uInt64 &npts, AccumType &mymin, AccumType &mymax)
 
void _computeStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 count, const ChunkType &chunk)
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
 
virtual void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
 
virtual StatisticsData::ALGORITHM algorithm() const
get the algorithm that this object uses for computing stats
 
virtual AccumType getMedianAbsDevMed(std::shared_ptr< uInt64 > knownNpts=nullptr, std::shared_ptr< AccumType > knownMin=nullptr, std::shared_ptr< AccumType > knownMax=nullptr, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt nBins=10000)
get the median of the absolute deviation about the median of the data.
 
virtual StatsData< AccumType > & _getStatsData()
Retrieve stats structure.
 
void _computeMinMax(std::shared_ptr< AccumType > &mymax, std::shared_ptr< AccumType > &mymin, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const ChunkType &chunk)
 
void _computeNpts(uInt64 &npts, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const ChunkType &chunk)
 
virtual void setCalculateAsAdded(Bool c)
Should statistics be updated with calls to addData or should they only be calculated upon calls to ge...
 
void _addData()
Allows derived classes to do things after data is set or added.
 
virtual void _minMaxNpts(uInt64 &npts, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
 
virtual void getMinMax(AccumType &mymin, AccumType &mymax)
scan the dataset(s) that have been added, and find the min and max.
 
void _doNptsMinMax(uInt64 &mynpts, AccumType &mymin, AccumType &mymax, std::shared_ptr< uInt64 > knownNpts, std::shared_ptr< AccumType > knownMin, std::shared_ptr< AccumType > knownMax)
for quantile computations, if necessary, determines npts, min, max to send to quantile calculator met...
 
Bool _getDoMaxMin() const
 
StatsData< AccumType > _statsData
 
uInt64 _doMinMaxNpts(AccumType &vmin, AccumType &vmax)
 
ClassicalStatistics(std::shared_ptr< ClassicalQuantileComputer< CASA_STATP > > qc)
This constructor should be used by derived objects in order to set the proper quantile computer objec...
 
Base class of statistics algorithm class hierarchy.
 
ALGORITHM
implemented algorithms
 
Abstract base class which defines interface for providing "datasets" to the statistics framework in c...
 
this file contains all the compiler specific defines
 
bool Bool
Define the standard types used by Casacore.
 
unsigned long long uInt64
 
std::pair< Int64, Int64 > LocationType
 
holds information about a data chunk.