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>
57template <
class AccumType,
class DataIterator,
class MaskIterator =
const Bool*,
58 class WeightsIterator = DataIterator>
125 virtual AccumType
getMedian(std::shared_ptr<uInt64> knownNpts =
nullptr,
126 std::shared_ptr<AccumType> knownMin =
nullptr,
127 std::shared_ptr<AccumType> knownMax =
nullptr,
128 uInt binningThreshholdSizeBytes = 4096 * 4096,
139 const std::set<Double>& fractions,
140 std::shared_ptr<uInt64> knownNpts =
nullptr,
141 std::shared_ptr<AccumType> knownMin =
nullptr,
142 std::shared_ptr<AccumType> knownMax =
nullptr,
143 uInt binningThreshholdSizeBytes = 4096 * 4096,
148 std::shared_ptr<AccumType> knownMin =
nullptr,
149 std::shared_ptr<AccumType> knownMax =
nullptr,
150 uInt binningThreshholdSizeBytes = 4096 * 4096,
155 virtual std::map<Double, AccumType>
getQuantiles(
const std::set<Double>& fractions,
156 std::shared_ptr<uInt64> knownNpts =
nullptr,
157 std::shared_ptr<AccumType> knownMin =
nullptr,
158 std::shared_ptr<AccumType> knownMax =
nullptr,
159 uInt binningThreshholdSizeBytes = 4096 * 4096,
170 virtual void getMinMax(AccumType& mymin, AccumType& mymax);
219 uInt dataStride)
const;
225 const MaskIterator& maskBegin,
uInt maskStride)
const;
228 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
229 Bool isInclude)
const;
232 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride)
const;
235 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
239 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
240 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
241 Bool isInclude)
const;
244 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
245 const MaskIterator& maskBegin,
uInt maskStride)
const;
275 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
276 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride)
const;
278 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
279 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
282 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
283 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
284 const MaskIterator& maskBegin,
uInt maskStride)
const;
286 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
287 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
288 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
289 Bool isInclude)
const;
291 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
292 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
295 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
296 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
299 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
300 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
301 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
304 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
305 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
uInt64 nr,
306 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride)
const;
312 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
316 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
318 Bool isInclude)
const;
321 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
322 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
323 uInt maskStride)
const;
326 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
327 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
331 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
332 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride)
const;
335 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
336 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
340 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
341 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
342 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
343 Bool isInclude)
const;
346 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
347 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
348 const MaskIterator& maskBegin,
uInt maskStride)
const;
358 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride);
362 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
366 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
367 const MaskIterator& maskBegin,
uInt maskStride);
370 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
371 const MaskIterator& maskBegin,
uInt maskStride,
380 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
384 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
388 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
389 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
393 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
394 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
402 std::shared_ptr<ClassicalQuantileComputer<CASA_STATP>>
_qComputer{};
404 void _computeMinMax(std::shared_ptr<AccumType>& mymax, std::shared_ptr<AccumType>& mymin,
405 DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter,
409 std::shared_ptr<AccumType>& mymin, DataIterator dataIter,
410 MaskIterator maskIter, WeightsIterator weightsIter,
uInt64 dataCount,
414 WeightsIterator weightsIter,
uInt64 dataCount,
const ChunkType& chunk);
417 DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter,
430 std::shared_ptr<uInt64> knownNpts, std::shared_ptr<AccumType> knownMin,
431 std::shared_ptr<AccumType> knownMax);
436#ifndef CASACORE_NO_AUTO_TEMPLATES
437#include <casacore/scimath/StatsFramework/ClassicalStatistics.tcc>
This class is used internally by ClassicalStatistics objects.
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...
ALGORITHM
implemented algorithms
Abstract base class which defines interface for providing "datasets" to the statistics framework in c...
For temporary backward namespace compatibility, use casa as alias for casacore.
std::pair< Int64, Int64 > LocationType
bool Bool
Define the standard types used by Casacore.
unsigned long long uInt64
holds information about a data chunk.