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>
45template <
class AccumType,
class DataIterator,
class MaskIterator =
const Bool*,
46 class WeightsIterator = DataIterator>
96 virtual AccumType
getMedian(std::shared_ptr<uInt64> knownNpts =
nullptr,
97 std::shared_ptr<AccumType> knownMin =
nullptr,
98 std::shared_ptr<AccumType> knownMax =
nullptr,
99 uInt binningThreshholdSizeBytes = 4096 * 4096,
104 std::shared_ptr<AccumType> knownMin =
nullptr,
105 std::shared_ptr<AccumType> knownMax =
nullptr,
106 uInt binningThreshholdSizeBytes = 4096 * 4096,
115 const std::set<Double>& quantiles,
116 std::shared_ptr<uInt64> knownNpts =
nullptr,
117 std::shared_ptr<AccumType> knownMin =
nullptr,
118 std::shared_ptr<AccumType> knownMax =
nullptr,
119 uInt binningThreshholdSizeBytes = 4096 * 4096,
124 virtual std::map<Double, AccumType>
getQuantiles(
const std::set<Double>& quantiles,
125 std::shared_ptr<uInt64> knownNpts =
nullptr,
126 std::shared_ptr<AccumType> knownMin =
nullptr,
127 std::shared_ptr<AccumType> knownMax = NULL,
128 uInt binningThreshholdSizeBytes = 4096 * 4096,
134 virtual void getMinMax(AccumType& mymin, AccumType& mymax);
170 uInt dataStride)
const;
176 const MaskIterator& maskBegin,
uInt maskStride)
const;
179 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
180 Bool isInclude)
const;
183 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride)
const;
186 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
190 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
191 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
192 Bool isInclude)
const;
195 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
196 const MaskIterator& maskBegin,
uInt maskStride)
const;
204 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
205 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride)
const;
207 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
208 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
211 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
212 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
213 const MaskIterator& maskBegin,
uInt maskStride)
const;
215 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
216 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
217 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
218 Bool isInclude)
const;
220 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
221 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
224 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
225 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
228 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
229 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
230 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
233 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
234 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
uInt64 nr,
235 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride)
const;
241 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
245 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
247 Bool isInclude)
const;
250 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
251 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
252 uInt maskStride)
const;
255 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
256 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
260 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
261 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride)
const;
264 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
265 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
269 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
270 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
271 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
272 Bool isInclude)
const;
275 std::shared_ptr<AccumType>& mymax,
const DataIterator& dataBegin,
276 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
277 const MaskIterator& maskBegin,
uInt maskStride)
const;
282 void _setRange(std::shared_ptr<std::pair<AccumType, AccumType>> r);
290 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride);
294 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
298 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
299 const MaskIterator& maskBegin,
uInt maskStride);
302 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
303 const MaskIterator& maskBegin,
uInt maskStride,
310 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
314 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
318 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
319 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
323 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
324 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
329 std::shared_ptr<std::pair<AccumType, AccumType>>
_range{};
334#ifndef CASACORE_NO_AUTO_TEMPLATES
335#include <casacore/scimath/StatsFramework/ConstrainedRangeStatistics.tcc>
Basic concrete QuantileComputer class for data constrained to be in a specified range.
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
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