26#ifndef SCIMATH_CONSTRAINEDRANGESTATISTICS_H
27#define SCIMATH_CONSTRAINEDRANGESTATISTICS_H
29#include <casacore/casa/aips.h>
31#include <casacore/scimath/StatsFramework/ClassicalStatistics.h>
32#include <casacore/scimath/StatsFramework/ConstrainedRangeQuantileComputer.h>
46 class AccumType,
class DataIterator,
class MaskIterator=
const Bool*,
47 class WeightsIterator=DataIterator
100 std::shared_ptr<uInt64> knownNpts=
nullptr,
101 std::shared_ptr<AccumType> knownMin=
nullptr,
102 std::shared_ptr<AccumType> knownMax=
nullptr,
103 uInt binningThreshholdSizeBytes=4096*4096,
109 std::shared_ptr<uInt64> knownNpts=
nullptr,
110 std::shared_ptr<AccumType> knownMin=
nullptr,
111 std::shared_ptr<AccumType> knownMax=
nullptr,
112 uInt binningThreshholdSizeBytes=4096*4096,
122 std::map<Double, AccumType>& quantileToValue,
123 const std::set<Double>& quantiles,
124 std::shared_ptr<uInt64> knownNpts=
nullptr,
125 std::shared_ptr<AccumType> knownMin=
nullptr,
126 std::shared_ptr<AccumType> knownMax=
nullptr,
127 uInt binningThreshholdSizeBytes=4096*4096,
134 const std::set<Double>& quantiles,
135 std::shared_ptr<uInt64> knownNpts=
nullptr,
136 std::shared_ptr<AccumType> knownMin=
nullptr,
137 std::shared_ptr<AccumType> knownMax=NULL,
138 uInt binningThreshholdSizeBytes=4096*4096,
144 virtual void getMinMax(AccumType& mymin, AccumType& mymax);
191 const DataIterator& dataStart,
uInt64 nr,
uInt dataStride,
197 const MaskIterator& maskBegin,
uInt maskStride
202 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
203 const MaskIterator& maskBegin,
uInt maskStride,
208 uInt64& npts,
const DataIterator& dataBegin,
209 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride
213 uInt64& npts,
const DataIterator& dataBegin,
214 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
219 uInt64& npts,
const DataIterator& dataBegin,
220 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
221 const MaskIterator& maskBegin,
uInt maskStride,
226 uInt64& npts,
const DataIterator& dataBegin,
227 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
228 const MaskIterator& maskBegin,
uInt maskStride
238 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
239 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride
243 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
244 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
249 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
250 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
251 const MaskIterator& maskBegin,
uInt maskStride
255 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
256 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
257 const MaskIterator& maskBegin,
uInt maskStride,
262 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
263 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
268 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
269 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
274 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
275 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
276 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
281 std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
282 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
283 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
291 uInt64& npts, std::shared_ptr<AccumType>& mymin,
292 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
uInt64 nr,
297 uInt64& npts, std::shared_ptr<AccumType>& mymin,
298 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
uInt64 nr,
303 uInt64& npts, std::shared_ptr<AccumType>& mymin,
304 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
uInt64 nr,
305 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride
309 uInt64& npts, std::shared_ptr<AccumType>& mymin,
310 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
uInt64 nr,
311 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
316 uInt64& npts, std::shared_ptr<AccumType>& mymin,
317 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
318 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride
322 uInt64& npts, std::shared_ptr<AccumType>& mymin,
323 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
324 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
329 uInt64& npts, std::shared_ptr<AccumType>& mymin,
330 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
331 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
332 const MaskIterator& maskBegin,
uInt maskStride,
337 uInt64& npts, std::shared_ptr<AccumType>& mymin,
338 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
339 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
340 const MaskIterator& maskBegin,
uInt maskStride
346 void _setRange(std::shared_ptr<std::pair<AccumType, AccumType>> r);
355 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride
361 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
367 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
368 const MaskIterator& maskBegin,
uInt maskStride
373 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
374 const MaskIterator& maskBegin,
uInt maskStride,
383 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
389 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
395 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
396 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
402 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
403 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
410 std::shared_ptr<std::pair<AccumType, AccumType>>
_range{};
416#ifndef CASACORE_NO_AUTO_TEMPLATES
417#include <casacore/scimath/StatsFramework/ConstrainedRangeStatistics.tcc>
Class to calculate statistics in a "classical" sense, ie using accumulators with no special filtering...
Basic concrete QuantileComputer class for data constrained to be in a specified range.
Abstract base class for statistics algorithms which are characterized by a range of good values.
virtual ~ConstrainedRangeStatistics()
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 _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 LocationType getStatisticIndex(StatisticsData::STATS stat)
see base class description
virtual void _unweightedStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride)
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, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
virtual void reset()
reset object to initial state.
ConstrainedRangeStatistics()=delete
virtual StatsData< AccumType > _getStatistics()
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataStart, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
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 _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
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.
std::shared_ptr< std::pair< AccumType, AccumType > > _range
ConstrainedRangeStatistics(const ConstrainedRangeStatistics< CASA_STATP > &other)
copy semantics
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
ConstrainedRangeStatistics(std::shared_ptr< ConstrainedRangeQuantileComputer< CASA_STATP > > qc)
Concrete derived classes are responsible for providing an appropriate QuantileComputer object to the ...
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, const DataRanges &ranges, Bool isInclude)
virtual std::map< Double, AccumType > getQuantiles(const std::set< Double > &quantiles, std::shared_ptr< uInt64 > knownNpts=nullptr, std::shared_ptr< AccumType > knownMin=nullptr, std::shared_ptr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt nBins=10000)
Get the specified quantiles.
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 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 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 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 _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
virtual void getMinMax(AccumType &mymin, AccumType &mymax)
get the min and max of the data set
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 &dataStart, uInt64 nr, uInt dataStride) const
scan through the data set to determine the number of good (unmasked, weight > 0, within range) points...
ConstrainedRangeStatistics< CASA_STATP > & operator=(const ConstrainedRangeStatistics< CASA_STATP > &other)
copy semantics
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 &weightsBegin, 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, 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, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
virtual AccumType _getStatistic(StatisticsData::STATS stat)
virtual void _accumNpts(uInt64 &npts, 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)
has weights, but no mask, no ranges
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 _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 _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 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 _setRange()=0
derived classes need to implement how to set their respective range
virtual void _accumNpts(uInt64 &npts, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, 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, std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
void _setRange(std::shared_ptr< std::pair< AccumType, AccumType > > r)
This method is purposefully non-virtual.
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 AccumType getMedianAndQuantiles(std::map< Double, AccumType > &quantileToValue, const std::set< Double > &quantiles, 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 _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 void _minMax(std::shared_ptr< AccumType > &mymin, std::shared_ptr< AccumType > &mymax, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
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