26 #ifndef SCIMATH_CLASSICALQUANTILECOMPUTER_H
27 #define SCIMATH_CLASSICALQUANTILECOMPUTER_H
29 #include <casacore/scimath/StatsFramework/StatisticsAlgorithmQuantileComputer.h>
31 #include <casacore/scimath/StatsFramework/StatisticsUtilities.h>
33 #include <casacore/casa/aips.h>
47 class AccumType,
class DataIterator,
class MaskIterator=
const Bool*,
48 class WeightsIterator=DataIterator
79 uInt64 mynpts, AccumType mymin, AccumType mymax,
80 uInt binningThreshholdSizeBytes,
Bool persistSortedArray,
uInt nBins
85 uInt64 mynpts, AccumType mymin, AccumType mymax,
86 uInt binningThreshholdSizeBytes,
Bool persistSortedArray,
uInt nBins
97 std::map<Double, AccumType>& quantiles,
98 const std::set<Double>& fractions,
uInt64 mynpts, AccumType mymin,
99 AccumType mymax,
uInt binningThreshholdSizeBytes,
106 const std::set<Double>& fractions,
uInt64 mynpts, AccumType mymin,
107 AccumType mymax,
uInt binningThreshholdSizeBytes,
123 std::vector<std::vector<uInt64> >& binCounts,
125 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
uInt64 nr,
127 const std::vector<AccumType>& maxLimit
131 std::vector<std::vector<uInt64> >& binCounts,
133 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
uInt64 nr,
136 const std::vector<AccumType>& maxLimit
140 std::vector<std::vector<uInt64> >& binCounts,
142 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
uInt64 nr,
143 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
145 const std::vector<AccumType>& maxLimit
149 std::vector<std::vector<uInt64> >& binCounts,
151 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
uInt64 nr,
152 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
155 const std::vector<AccumType>& maxLimit
159 std::vector<std::vector<uInt64> >& binCounts,
161 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
162 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
164 const std::vector<AccumType>& maxLimit
168 std::vector<std::vector<uInt64> >& binCounts,
170 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
171 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
174 const std::vector<AccumType>& maxLimit
178 std::vector<std::vector<uInt64> >& binCounts,
180 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
181 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
182 const MaskIterator& maskBegin,
uInt maskStride,
185 const std::vector<AccumType>& maxLimit
189 std::vector<std::vector<uInt64> >& binCounts,
191 std::vector<Bool>& allSame,
const DataIterator& dataBegin,
192 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
193 const MaskIterator& maskBegin,
uInt maskStride,
195 const std::vector<AccumType>& maxLimit
203 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
uInt64 nr,
209 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
uInt64 nr,
214 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
215 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
221 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
uInt64 nr,
222 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
228 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
229 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride
234 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
235 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
241 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
242 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
243 const MaskIterator& maskBegin,
uInt maskStride
248 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
249 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
250 const MaskIterator& maskBegin,
uInt maskStride,
263 std::vector<std::vector<AccumType>>& arys,
uInt64& currentCount,
264 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
270 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
271 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
277 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
278 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
279 const MaskIterator& maskBegin,
uInt maskStride,
285 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
286 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
287 const MaskIterator& maskBegin,
uInt maskStride,
294 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
295 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
302 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
303 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
310 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
311 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
312 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
318 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
319 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
320 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
329 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
335 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
uInt64 nr,
342 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
343 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
349 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
uInt64 nr,
350 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
356 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
357 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
363 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
364 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
370 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
371 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
372 const MaskIterator& maskBegin,
uInt maskStride,
uInt maxElements
377 std::vector<AccumType>& ary,
const DataIterator& dataBegin,
378 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
379 const MaskIterator& maskBegin,
uInt maskStride,
392 std::map<uInt64, AccumType>& values,
uInt64 mynpts,
393 const std::set<uInt64>& indices,
uInt64 maxArraySize,
394 Bool persistSortedArray
416 std::vector<std::vector<uInt64>>& bins,
418 std::vector<Bool>& allSame, DataIterator dataIter,
419 MaskIterator maskIter, WeightsIterator weightsIter,
uInt64 count,
421 const std::vector<AccumType>& maxLimit,
426 std::vector<AccumType>& ary, DataIterator dataIter,
427 MaskIterator maskIter, WeightsIterator weightsIter,
uInt64 dataCount,
432 std::vector<std::vector<AccumType> >& arys,
uInt64& currentCount,
433 DataIterator dataIter, MaskIterator maskIter,
434 WeightsIterator weightsIter,
uInt64 dataCount,
446 std::vector<std::vector<AccumType>>& arrays,
461 uInt64 maxArraySize,
const std::vector<IndexSet>& dataIndices,
466 const std::vector<uInt64>& binNpts,
uInt64 maxArraySize,
468 const std::vector<IndexSet>& dataIndices,
uInt nBins
474 uInt64 mynpts, AccumType mymin, AccumType mymax,
uInt64 maxArraySize,
486 #ifndef CASACORE_NO_AUTO_TEMPLATES
487 #include <casacore/scimath/StatsFramework/ClassicalQuantileComputer.tcc>
This class is used internally by ClassicalStatistics objects.
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude, uInt maxElements) const
mask and ranges
ClassicalQuantileComputer()=delete
std::set< uInt64 > IndexSet
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
populate an unsorted array with valid data.
std::vector< IndexValueMap > _dataFromMultipleBins(const std::vector< StatsHistogram< AccumType > > &hist, uInt64 maxArraySize, const std::vector< IndexSet > &dataIndices, uInt nBins)
extract data from multiple histograms given by hist.
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
static IndexSet _medianIndices(uInt64 mynpts)
get the index (for odd npts) or indices (for even npts) of the median of the sorted array.
virtual void reset()
reset the private fields
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude, uInt maxElements) const
weights, mask, ranges
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
mask and ranges
ClassicalQuantileComputer(StatisticsDataset< CASA_STATP > *dataset)
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
ranges
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const IncludeLimits &includeLimits, uInt64 maxCount) const
weights
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
IndexValueMap _indicesToValues(uInt64 mynpts, AccumType mymin, AccumType mymax, uInt64 maxArraySize, const IndexSet &dataIndices, Bool persistSortedArray, uInt nBins)
get the values for the specified indices in the sorted array of all good data
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
virtual std::map< Double, AccumType > getQuantiles(const std::set< Double > &fractions, uInt64 mynpts, AccumType mymin, AccumType mymax, uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins)
Get the specified Quantiles.
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
weights
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
weights and ranges
virtual AccumType getMedianAndQuantiles(std::map< Double, AccumType > &quantiles, const std::set< Double > &fractions, uInt64 mynpts, AccumType mymin, AccumType mymax, uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins)
If one needs to compute both the median and QuantileComputer values, it is better to call getMedianAn...
void _computeBins(std::vector< std::vector< uInt64 >> &bins, std::vector< CountedPtr< AccumType >> &sameVal, std::vector< Bool > &allSame, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 count, const std::vector< StatsHistogram< AccumType >> &hist, const std::vector< AccumType > &maxLimit, const typename StatisticsDataset< CASA_STATP >::ChunkData &chunk)
void _computeDataArray(std::vector< AccumType > &ary, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const typename StatisticsDataset< CASA_STATP >::ChunkData &chunk)
Bool _valuesFromSortedArray(std::map< uInt64, AccumType > &values, uInt64 mynpts, const std::set< uInt64 > &indices, uInt64 maxArraySize, Bool persistSortedArray)
get values from sorted array if the array is small enough to be held in memory.
typename std::map< uInt64, AccumType > IndexValueMap
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude, uInt maxElements) const
ranges
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
weights, mask, ranges
std::vector< IndexValueMap > _dataFromSingleBins(const std::vector< uInt64 > &binNpts, uInt64 maxArraySize, const IncludeLimits &binLimits, const std::vector< IndexSet > &dataIndices, uInt nBins)
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
virtual AccumType getMedian(uInt64 mynpts, AccumType mymin, AccumType mymax, uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins)
Caller is responsible for passing correct values of mynpts, mymin, and mymax; no checking is done for...
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude, const IncludeLimits &includeLimits, uInt64 maxCount) const
weights and ranges
virtual AccumType getMedianAbsDevMed(uInt64 mynpts, AccumType mymin, AccumType mymax, uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins)
get the median of the absolute deviation about the median of the data.
std::pair< AccumType, AccumType > LimitPair
void _createDataArrays(std::vector< std::vector< AccumType >> &arrays, const IncludeLimits &includeLimits, uInt64 maxCount)
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude, const IncludeLimits &includeLimits, uInt64 maxCount) const
ranges
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const IncludeLimits &includeLimits, uInt64 maxCount) const
weights and mask
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude, const IncludeLimits &includeLimits, uInt64 maxCount) const
weights, mask, ranges
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, uInt maxElements) const
weights and mask
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude, uInt maxElements) const
weights and ranges
void _computeDataArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const IncludeLimits &includeLimits, uInt64 maxCount, const typename StatisticsDataset< CASA_STATP >::ChunkData &chunk)
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude, const IncludeLimits &includeLimits, uInt64 maxCount) const
mask and ranges
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, uInt maxElements) const
mask
ClassicalQuantileComputer & operator=(const ClassicalQuantileComputer &other)
copy semantics
void _createDataArray(std::vector< AccumType > &array)
Create an unsorted array of the complete data set.
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 ¤tCount, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const IncludeLimits &includeLimits, uInt64 maxCount) const
AccumType _myMedian
for use in often repeatedly run macros
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
virtual StatisticsAlgorithmQuantileComputer< CASA_STATP > * clone() const
clone this object by returning a pointer to a copy
std::vector< std::vector< uInt64 > > _binCounts(std::vector< CountedPtr< AccumType > > &sameVal, const std::vector< StatsHistogram< AccumType > > &hist)
tally the number of data points that fall into each bin provided by hist.
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, uInt maxElements) const
no weights, no mask, no ranges
virtual ~ClassicalQuantileComputer()
typename std::vector< LimitPair >::const_iterator LimitPairVectorIter
virtual void _populateArrays(std::vector< std::vector< AccumType >> &arys, uInt64 ¤tCount, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const IncludeLimits &includeLimits, uInt64 maxCount) const
Create a std::vector of unsorted arrays, one array for each bin defined by includeLimits.
virtual void _populateArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
weights and mask
ClassicalQuantileComputer(const ClassicalQuantileComputer &other)
copy semantics
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< CountedPtr< AccumType > > &sameVal, std::vector< Bool > &allSame, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const std::vector< StatsHistogram< AccumType > > &hist, const std::vector< AccumType > &maxLimit) const
Get the counts of data within the specified histogram bins.
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, uInt maxElements) const
weights
This is the virtual base class from which concrete QuantileComputer classes are derived.
Represents an unfilled histogram with equal width bins for binning used for quantile computations.
this file contains all the compiler specific defines
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
bool Bool
Define the standard types used by Casacore.
unsigned long long uInt64