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>
60 class AccumType,
class DataIterator,
class MaskIterator=
const Bool*,
61 class WeightsIterator=DataIterator
138 uInt binningThreshholdSizeBytes=4096*4096,
150 std::map<Double, AccumType>& quantiles,
154 uInt binningThreshholdSizeBytes=4096*4096,
163 uInt binningThreshholdSizeBytes=4096*4096,
170 const std::set<Double>& fractions,
174 uInt binningThreshholdSizeBytes=4096*4096,
185 virtual void getMinMax(AccumType& mymin, AccumType& mymax);
188 uInt64& npts, AccumType& mymin, AccumType& mymax
251 const MaskIterator& maskBegin,
uInt maskStride
256 const MaskIterator& maskBegin,
uInt maskStride,
261 uInt64& npts,
const DataIterator& dataBegin,
262 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride
266 uInt64& npts,
const DataIterator& dataBegin,
267 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
272 uInt64& npts,
const DataIterator& dataBegin,
273 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
274 const MaskIterator& maskBegin,
uInt maskStride,
279 uInt64& npts,
const DataIterator& dataBegin,
280 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
281 const MaskIterator& maskBegin,
uInt maskStride
320 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride
325 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
331 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
332 const MaskIterator& maskBegin,
uInt maskStride
337 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
338 const MaskIterator& maskBegin,
uInt maskStride,
344 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
350 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
356 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
357 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
363 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
364 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
386 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride
392 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
399 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride
405 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
412 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
413 const MaskIterator& maskBegin,
uInt maskStride,
420 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
421 const MaskIterator& maskBegin,
uInt maskStride
434 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride
440 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
446 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
447 const MaskIterator& maskBegin,
uInt maskStride
452 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
453 const MaskIterator& maskBegin,
uInt maskStride,
466 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
472 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
478 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
479 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
485 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
486 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
499 DataIterator dataIter, MaskIterator maskIter,
506 MaskIterator maskIter, WeightsIterator weightsIter,
uInt64 dataCount,
511 uInt64& npts, DataIterator dataIter, MaskIterator maskIter,
517 DataIterator dataIter, MaskIterator maskIter,
531 uInt64& mynpts, AccumType& mymin, AccumType& mymax,
540 #ifndef CASACORE_NO_AUTO_TEMPLATES
541 #include <casacore/scimath/StatsFramework/ClassicalStatistics.tcc>
Class to calculate statistics in a "classical" sense, ie using accumulators with no special filtering...
virtual void _minMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
virtual void reset()
reset object to initial state.
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 AccumType getMedianAbsDevMed(CountedPtr< uInt64 > knownNpts=nullptr, CountedPtr< AccumType > knownMin=nullptr, CountedPtr< 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 void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
void _computeMinMax(CountedPtr< AccumType > &mymax, CountedPtr< 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 StatsData< AccumType > _getInitialStats() const
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 void _minMax(CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
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, CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) 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 StatsData< AccumType > _getStatistics()
typename StatisticsDataset< CASA_STATP >::ChunkData ChunkType
virtual AccumType _getStatistic(StatisticsData::STATS stat)
virtual std::pair< Int64, Int64 > getStatisticIndex(StatisticsData::STATS stat)
see base class description
CountedPtr< ClassicalQuantileComputer< CASA_STATP > > _qComputer
void setQuantileComputer(CountedPtr< ClassicalQuantileComputer< CASA_STATP >> qc)
Allow derived objects to set the quantile computer object.
virtual void _minMax(CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
virtual uInt64 getNPts()
scan the dataset(s) that have been added, and find the number of good points.
virtual void _minMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
Sometimes we want the min, max, and npts all in one scan.
virtual StatisticsAlgorithm< CASA_STATP > * clone() const
Clone this instance.
virtual const StatsData< AccumType > & _getStatsData() const
virtual AccumType getMedianAndQuantiles(std::map< Double, AccumType > &quantiles, const std::set< Double > &fractions, CountedPtr< uInt64 > knownNpts=nullptr, CountedPtr< AccumType > knownMin=nullptr, CountedPtr< 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 _accumNpts(uInt64 &npts, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
void _doNptsMinMax(uInt64 &mynpts, AccumType &mymin, AccumType &mymax, CountedPtr< uInt64 > knownNpts, CountedPtr< AccumType > knownMin, CountedPtr< AccumType > knownMax)
for quantile computations, if necessary, determines npts, min, max to send to quantile calculator met...
virtual void _minMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
virtual void _minMax(CountedPtr< AccumType > &mymin, CountedPtr< 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 _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride)
has weights, but no mask, no ranges
virtual void _minMax(CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightBegin, 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, const DataRanges &ranges, Bool isInclude)
virtual void _updateDataProviderMaxMin(const StatsData< AccumType > &threadStats)
virtual StatsData< AccumType > & _getStatsData()
Retrieve stats structure.
void _accumulate(StatsData< AccumType > &stats, const AccumType &datum, const AccumType &weight, const LocationType &location)
virtual void _minMax(CountedPtr< AccumType > &mymin, CountedPtr< 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.
ClassicalStatistics(CountedPtr< ClassicalQuantileComputer< CASA_STATP > > qc)
This constructor should be used by derived objects in order to set the proper quantile computer objec...
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 _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
virtual void _minMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
void _doMinMax(AccumType &vmin, AccumType &vmax)
scan dataset(s) to find min and max
ClassicalStatistics(const ClassicalStatistics &cs)
copy semantics
CountedPtr< StatisticsAlgorithmQuantileComputer< CASA_STATP > > _getQuantileComputer()
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
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)
virtual AccumType getMedian(CountedPtr< uInt64 > knownNpts=nullptr, CountedPtr< AccumType > knownMin=nullptr, CountedPtr< 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...
void _computeStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 count, const ChunkType &chunk)
virtual void _minMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, 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 StatisticsData::ALGORITHM algorithm() const
get the algorithm that this object uses for computing stats
virtual std::map< Double, AccumType > getQuantiles(const std::set< Double > &fractions, CountedPtr< uInt64 > knownNpts=nullptr, CountedPtr< AccumType > knownMin=nullptr, CountedPtr< AccumType > knownMax=nullptr, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt nBins=10000)
Get the specified quantiles.
void _computeNpts(uInt64 &npts, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const ChunkType &chunk)
virtual void _minMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymin, CountedPtr< 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 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 _minMax(CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
ClassicalStatistics & operator=(const ClassicalStatistics &other)
copy semantics
virtual void _minMax(CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
virtual void getMinMax(AccumType &mymin, AccumType &mymax)
scan the dataset(s) that have been added, and find the min and max.
void _computeMinMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymax, CountedPtr< AccumType > &mymin, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const ChunkType &chunk)
Bool _getDoMaxMin() const
StatsData< AccumType > _statsData
virtual void _minMaxNpts(uInt64 &npts, CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
virtual void _minMax(CountedPtr< AccumType > &mymin, CountedPtr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
uInt64 _doMinMaxNpts(AccumType &vmin, AccumType &vmax)
Referenced counted pointer for constant data.
Base class of statistics algorithm class hierarchy.
ALGORITHM
implemented algorithms
Representation of a statistics dataset used in statistics framework calculatations.
const Double c
Fundamental physical constants (SI units):
this file contains all the compiler specific defines
bool Bool
Define the standard types used by Casacore.
PtrHolder(const PtrHolder< T > &other)
unsigned long long uInt64
std::pair< Int64, Int64 > LocationType