casacore
Loading...
Searching...
No Matches
ClassicalQuantileComputer.h
Go to the documentation of this file.
1// # Copyright (C) 2000,2001
2// # Associated Universities, Inc. Washington DC, USA.
3// #
4// # This library is free software; you can redistribute it and/or modify it
5// # under the terms of the GNU Library General Public License as published by
6// # the Free Software Foundation; either version 2 of the License, or (at your
7// # option) any later version.
8// #
9// # This library is distributed in the hope that it will be useful, but WITHOUT
10// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12// # License for more details.
13// #
14// # You should have received a copy of the GNU Library General Public License
15// # along with this library; if not, write to the Free Software Foundation,
16// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17// #
18// # Correspondence concerning AIPS++ should be addressed as follows:
19// # Internet email: casa-feedback@nrao.edu.
20// # Postal address: AIPS++ Project Office
21// # National Radio Astronomy Observatory
22// # 520 Edgemont Road
23// # Charlottesville, VA 22903-2475 USA
24// #
25
26#ifndef SCIMATH_CLASSICALQUANTILECOMPUTER_H
27#define SCIMATH_CLASSICALQUANTILECOMPUTER_H
28
29#include <casacore/scimath/StatsFramework/StatisticsAlgorithmQuantileComputer.h>
30
31#include <casacore/scimath/StatsFramework/StatisticsUtilities.h>
32
33#include <casacore/casa/aips.h>
34
35#include <map>
36#include <set>
37#include <utility>
38#include <vector>
39
40namespace casacore {
41
42// This class is used internally by ClassicalStatistics objects. It should never
43// be explicitly instantiated by an API developer. See the documentation of
44// StatisticsAlgorithm for details regarding QuantileComputer classes.
45
46template <class AccumType, class DataIterator, class MaskIterator = const Bool*,
47 class WeightsIterator = DataIterator>
49 using LimitPair = std::pair<AccumType, AccumType>;
50 using LimitPairVectorIter = typename std::vector<LimitPair>::const_iterator;
51 using IndexValueMap = typename std::map<uInt64, AccumType>;
52 using IndexSet = std::set<uInt64>;
53
54 public:
56
58
59 // copy semantics
61
63
64 // copy semantics
66
67 // clone this object by returning a pointer to a copy
69
70 // Caller is responsible for passing correct values of mynpts, mymin, and
71 // mymax; no checking is done for correctness in this method.
72 virtual AccumType getMedian(uInt64 mynpts, AccumType mymin, AccumType mymax,
73 uInt binningThreshholdSizeBytes, Bool persistSortedArray, uInt nBins);
74
75 // get the median of the absolute deviation about the median of the data.
76 virtual AccumType getMedianAbsDevMed(uInt64 mynpts, AccumType mymin, AccumType mymax,
77 uInt binningThreshholdSizeBytes, Bool persistSortedArray,
78 uInt nBins);
79
80 // If one needs to compute both the median and QuantileComputer values, it
81 // is better to call getMedianAndQuantiles() rather than getMedian() and
82 // getQuantiles() separately, as the first will scan large data sets fewer
83 // times than calling the separate methods. The return value is the median;
84 // the quantiles are returned in the <src>quantiles</src> map. Values in the
85 // <src>fractions</src> set represent the locations in the CDF and should be
86 // between 0 and 1, exclusive.
87 virtual AccumType getMedianAndQuantiles(std::map<Double, AccumType>& quantiles,
88 const std::set<Double>& fractions, uInt64 mynpts,
89 AccumType mymin, AccumType mymax,
90 uInt binningThreshholdSizeBytes, Bool persistSortedArray,
91 uInt nBins);
92
93 // Get the specified Quantiles. <src>fractions</src> must be between 0 and
94 // 1, noninclusive.
95 virtual std::map<Double, AccumType> getQuantiles(const std::set<Double>& fractions, uInt64 mynpts,
96 AccumType mymin, AccumType mymax,
97 uInt binningThreshholdSizeBytes,
98 Bool persistSortedArray, uInt nBins);
99
100 // reset the private fields
101 virtual void reset();
102
103 protected:
104 // <group>
105 // Get the counts of data within the specified histogram bins. The number of
106 // arrays within binCounts will be equal to the number of histograms in
107 // <src>hist</src>. Each array within <src>binCounts</src> will have the
108 // same number of elements as the number of bins in its corresponding
109 // histogram in <src>hist</src>.
110 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
111 std::vector<std::shared_ptr<AccumType>>& sameVal,
112 std::vector<Bool>& allSame, const DataIterator& dataBegin, uInt64 nr,
113 uInt dataStride, const std::vector<StatsHistogram<AccumType>>& hist,
114 const std::vector<AccumType>& maxLimit) const;
115
116 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
117 std::vector<std::shared_ptr<AccumType>>& sameVal,
118 std::vector<Bool>& allSame, const DataIterator& dataBegin, uInt64 nr,
119 uInt dataStride, const DataRanges& ranges, Bool isInclude,
120 const std::vector<StatsHistogram<AccumType>>& hist,
121 const std::vector<AccumType>& maxLimit) const;
122
123 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
124 std::vector<std::shared_ptr<AccumType>>& sameVal,
125 std::vector<Bool>& allSame, const DataIterator& dataBegin, uInt64 nr,
126 uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
127 const std::vector<StatsHistogram<AccumType>>& hist,
128 const std::vector<AccumType>& maxLimit) const;
129
130 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
131 std::vector<std::shared_ptr<AccumType>>& sameVal,
132 std::vector<Bool>& allSame, const DataIterator& dataBegin, uInt64 nr,
133 uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
134 const DataRanges& ranges, Bool isInclude,
135 const std::vector<StatsHistogram<AccumType>>& hist,
136 const std::vector<AccumType>& maxLimit) const;
137
138 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
139 std::vector<std::shared_ptr<AccumType>>& sameVal,
140 std::vector<Bool>& allSame, const DataIterator& dataBegin,
141 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
142 const std::vector<StatsHistogram<AccumType>>& hist,
143 const std::vector<AccumType>& maxLimit) const;
144
145 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
146 std::vector<std::shared_ptr<AccumType>>& sameVal,
147 std::vector<Bool>& allSame, const DataIterator& dataBegin,
148 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
149 const DataRanges& ranges, Bool isInclude,
150 const std::vector<StatsHistogram<AccumType>>& hist,
151 const std::vector<AccumType>& maxLimit) const;
152
153 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
154 std::vector<std::shared_ptr<AccumType>>& sameVal,
155 std::vector<Bool>& allSame, const DataIterator& dataBegin,
156 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
157 const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
158 Bool isInclude, const std::vector<StatsHistogram<AccumType>>& hist,
159 const std::vector<AccumType>& maxLimit) const;
160
161 virtual void _findBins(std::vector<std::vector<uInt64>>& binCounts,
162 std::vector<std::shared_ptr<AccumType>>& sameVal,
163 std::vector<Bool>& allSame, const DataIterator& dataBegin,
164 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
165 const MaskIterator& maskBegin, uInt maskStride,
166 const std::vector<StatsHistogram<AccumType>>& hist,
167 const std::vector<AccumType>& maxLimit) const;
168 // </group>
169
170 //<group>
171 // populate an unsorted array with valid data.
172 // no weights, no mask, no ranges
173 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin, uInt64 nr,
174 uInt dataStride) const;
175
176 // ranges
177 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin, uInt64 nr,
178 uInt dataStride, const DataRanges& ranges, Bool isInclude) const;
179
180 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin, uInt64 nr,
181 uInt dataStride, const MaskIterator& maskBegin,
182 uInt maskStride) const;
183
184 // mask and ranges
185 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin, uInt64 nr,
186 uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
187 const DataRanges& ranges, Bool isInclude) const;
188
189 // weights
190 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
191 const WeightsIterator& weightsBegin, uInt64 nr,
192 uInt dataStride) const;
193
194 // weights and ranges
195 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
196 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
197 const DataRanges& ranges, Bool isInclude) const;
198
199 // weights and mask
200 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
201 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
202 const MaskIterator& maskBegin, uInt maskStride) const;
203
204 // weights, mask, ranges
205 virtual void _populateArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
206 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
207 const MaskIterator& maskBegin, uInt maskStride,
208 const DataRanges& ranges, Bool isInclude) const;
209 // </group>
210
211 // <group>
212 // Create a std::vector of unsorted arrays, one array for each bin defined
213 // by <src>includeLimits</src>. <src>includeLimits</src> should be
214 // non-overlapping and should be given in ascending order (the algorithm
215 // used assumes this). Once the sum of the lengths of all arrays equals
216 // <src>maxCount</src> the method will return with no further processing.
217 // no weights, no mask, no ranges
218 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
219 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
220 const IncludeLimits& includeLimits, uInt64 maxCount) const;
221
222 // ranges
223 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
224 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
225 const DataRanges& ranges, Bool isInclude,
226 const IncludeLimits& includeLimits, uInt64 maxCount) const;
227
228 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
229 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
230 const MaskIterator& maskBegin, uInt maskStride,
231 const IncludeLimits& includeLimits, uInt64 maxCount) const;
232
233 // mask and ranges
234 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
235 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
236 const MaskIterator& maskBegin, uInt maskStride,
237 const DataRanges& ranges, Bool isInclude,
238 const IncludeLimits& includeLimits, uInt64 maxCount) const;
239
240 // weights
241 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
242 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
243 uInt64 nr, uInt dataStride, const IncludeLimits& includeLimits,
244 uInt64 maxCount) const;
245
246 // weights and ranges
247 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
248 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
249 uInt64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude,
250 const IncludeLimits& includeLimits, uInt64 maxCount) const;
251
252 // weights and mask
253 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
254 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
255 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
256 uInt maskStride, const IncludeLimits& includeLimits,
257 uInt64 maxCount) const;
258
259 // weights, mask, ranges
260 virtual void _populateArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
261 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
262 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
263 uInt maskStride, const DataRanges& ranges, Bool isInclude,
264 const IncludeLimits& includeLimits, uInt64 maxCount) const;
265 // </group>
266
267 // <group>
268 // no weights, no mask, no ranges
269 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
270 uInt64 nr, uInt dataStride, uInt maxElements) const;
271
272 // ranges
273 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
274 uInt64 nr, uInt dataStride, const DataRanges& ranges,
275 Bool isInclude, uInt maxElements) const;
276
277 // mask
278 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
279 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
280 uInt maskStride, uInt maxElements) const;
281
282 // mask and ranges
283 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
284 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
285 uInt maskStride, const DataRanges& ranges, Bool isInclude,
286 uInt maxElements) const;
287
288 // weights
289 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
290 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
291 uInt maxElements) const;
292
293 // weights and ranges
294 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
295 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
296 const DataRanges& ranges, Bool isInclude, uInt maxElements) const;
297
298 // weights and mask
299 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
300 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
301 const MaskIterator& maskBegin, uInt maskStride,
302 uInt maxElements) const;
303
304 // weights, mask, ranges
305 virtual Bool _populateTestArray(std::vector<AccumType>& ary, const DataIterator& dataBegin,
306 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
307 const MaskIterator& maskBegin, uInt maskStride,
308 const DataRanges& ranges, Bool isInclude, uInt maxElements) const;
309 // </group>
310
311 // get values from sorted array if the array is small enough to be held in
312 // memory. Note that this is the array containing all good data, not data in
313 // just a single bin representing a subset of good data.
314 // Returns True if the data were successfully retrieved.
315 // If True is returned, the values map will contain a map of index to value.
316 // It is the caller's responsibility to check that <src>mynpts</src> is not
317 // 0; no checking is done here.
318 Bool _valuesFromSortedArray(std::map<uInt64, AccumType>& values, uInt64 mynpts,
319 const std::set<uInt64>& indices, uInt64 maxArraySize,
320 Bool persistSortedArray);
321
322 private:
324 // for use in often repeatedly run macros
325 AccumType _myMedian{0};
326
327 // tally the number of data points that fall into each bin provided by
328 // <src>hist</src>. Any points that are less than hist.minLimit or greater
329 // than hist.minLimit + hist.nBins*hist.binWidth are not included in the
330 // counts. A data point that falls exactly on a bin boundary is considered
331 // to be in the higher index bin. <src>sameVal</src> will be non-null if all
332 // the good values in the histogram range are the same. In that case, the
333 // value held will be the value of each of those data points.
334 std::vector<std::vector<uInt64>> _binCounts(std::vector<std::shared_ptr<AccumType>>& sameVal,
335 const std::vector<StatsHistogram<AccumType>>& hist);
336
337 void _computeBins(std::vector<std::vector<uInt64>>& bins,
338 std::vector<std::shared_ptr<AccumType>>& sameVal, std::vector<Bool>& allSame,
339 DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter,
340 uInt64 count, const std::vector<StatsHistogram<AccumType>>& hist,
341 const std::vector<AccumType>& maxLimit,
342 const typename StatisticsDataset<CASA_STATP>::ChunkData& chunk);
343
344 void _computeDataArray(std::vector<AccumType>& ary, DataIterator dataIter, MaskIterator maskIter,
345 WeightsIterator weightsIter, uInt64 dataCount,
346 const typename StatisticsDataset<CASA_STATP>::ChunkData& chunk);
347
348 void _computeDataArrays(std::vector<std::vector<AccumType>>& arys, uInt64& currentCount,
349 DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter,
350 uInt64 dataCount, const IncludeLimits& includeLimits, uInt64 maxCount,
351 const typename StatisticsDataset<CASA_STATP>::ChunkData& chunk);
352
353 // Create an unsorted array of the complete data set. If
354 // <src>includeLimits</src> is specified, only points within those limits
355 // (including min but excluding max, as per definition of bins), are
356 // included.
357 void _createDataArray(std::vector<AccumType>& array);
358
359 void _createDataArrays(std::vector<std::vector<AccumType>>& arrays,
360 const IncludeLimits& includeLimits, uInt64 maxCount);
361
362 // extract data from multiple histograms given by <src>hist</src>.
363 // <src>dataIndices</src> represent the indices of the sorted arrays of
364 // values to extract. There should be exactly one set of data indices to
365 // extract for each supplied histogram. The data indices are relative to the
366 // minimum value of the minimum bin in their respective histograms. The
367 // ordering of the maps in the returned std::vector represent the ordering
368 // of histograms in <src>hist</src>. <src>hist</src> should contain
369 // non-overlapping histograms and the histograms should be specified in
370 // ascending order.
371 std::vector<IndexValueMap> _dataFromMultipleBins(
372 const std::vector<StatsHistogram<AccumType>>& hist, uInt64 maxArraySize,
373 const std::vector<IndexSet>& dataIndices, uInt nBins);
374
375 std::vector<IndexValueMap> _dataFromSingleBins(const std::vector<uInt64>& binNpts,
376 uInt64 maxArraySize,
377 const IncludeLimits& binLimits,
378 const std::vector<IndexSet>& dataIndices,
379 uInt nBins);
380
381 // get the values for the specified indices in the sorted array of all good
382 // data
383 IndexValueMap _indicesToValues(uInt64 mynpts, AccumType mymin, AccumType mymax,
384 uInt64 maxArraySize, const IndexSet& dataIndices,
385 Bool persistSortedArray, uInt nBins);
386
387 // get the index (for odd npts) or indices (for even npts) of the median of
388 // the sorted array.
390};
391
392} // namespace casacore
393
394#ifndef CASACORE_NO_AUTO_TEMPLATES
395#include <casacore/scimath/StatsFramework/ClassicalQuantileComputer.tcc>
396#endif
397
398#endif
#define DataRanges
#define IncludeLimits
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
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
populate an unsorted array with valid data.
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 StatisticsAlgorithmQuantileComputer< CASA_STATP > * clone() const
clone this object by returning a pointer to a copy
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
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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 void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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
ClassicalQuantileComputer(StatisticsDataset< CASA_STATP > *dataset)
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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 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 &currentCount, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const IncludeLimits &includeLimits, uInt64 maxCount) const
weights
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 _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
ClassicalQuantileComputer & operator=(const ClassicalQuantileComputer &other)
copy semantics
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...
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 &currentCount, 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.
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
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 &currentCount, 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.
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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 _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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
std::pair< AccumType, AccumType > LimitPair
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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
virtual void _populateArrays(std::vector< std::vector< AccumType > > &arys, uInt64 &currentCount, 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 &currentCount, 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 &currentCount, 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
void _createDataArrays(std::vector< std::vector< AccumType > > &arrays, const IncludeLimits &includeLimits, uInt64 maxCount)
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 &currentCount, 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 &currentCount, 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 Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, uInt maxElements) const
mask
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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
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 &currentCount, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const IncludeLimits &includeLimits, uInt64 maxCount) const
std::vector< std::vector< uInt64 > > _binCounts(std::vector< std::shared_ptr< AccumType > > &sameVal, const std::vector< StatsHistogram< AccumType > > &hist)
tally the number of data points that fall into each bin provided by hist.
AccumType _myMedian
for use in often repeatedly run macros
void _computeBins(std::vector< std::vector< uInt64 > > &bins, std::vector< std::shared_ptr< 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)
virtual Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, uInt maxElements) const
no weights, no mask, no ranges
virtual void _findBins(std::vector< std::vector< uInt64 > > &binCounts, std::vector< std::shared_ptr< 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
typename std::vector< LimitPair >::const_iterator LimitPairVectorIter
std::vector< IndexValueMap > _dataFromSingleBins(const std::vector< uInt64 > &binNpts, uInt64 maxArraySize, const IncludeLimits &binLimits, const std::vector< IndexSet > &dataIndices, uInt nBins)
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 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 Bool _populateTestArray(std::vector< AccumType > &ary, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, uInt maxElements) const
weights
Representation of a statistics dataset used in statistics framework calculatations.
Represents an unfilled histogram with equal width bins for binning used for quantile computations.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
T * array
The actual storage.
Definition Block.h:689
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
unsigned long long uInt64
Definition aipsxtype.h:37
holds information about a data chunk.