casacore
Loading...
Searching...
No Matches
ClassicalStatistics.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_CLASSICALSTATISTICSS_H
27#define SCIMATH_CLASSICALSTATISTICSS_H
28
29#include <casacore/casa/aips.h>
30
31#include <casacore/scimath/StatsFramework/StatisticsAlgorithm.h>
32
33#include <casacore/scimath/StatsFramework/ClassicalQuantileComputer.h>
34#include <casacore/scimath/StatsFramework/StatisticsTypes.h>
35#include <casacore/scimath/StatsFramework/StatisticsUtilities.h>
36#include <set>
37#include <vector>
38#include <utility>
39
40namespace casacore {
41
42// Class to calculate statistics in a "classical" sense, ie using accumulators
43// with no special filtering beyond optional range filtering etc.
44//
45// setCalculateAsAdded() allows one to specify if statistics should be
46// calculated and updated on upon each call to set/addData(). If False,
47// statistics will be calculated only when getStatistic(), getStatistics(), or
48// similar statistics computing methods are called. Setting this value to True
49// allows the caller to not have to keep all the data accessible at once. Note
50// however, that all data must be simultaneously accessible if quantile-like
51// (eg median) calculations are desired.
52//
53// Objects of this class are instantiated using a ClassicalQuantileComputer
54// object for computation of quantile-like statistics. See the documentation
55// of StatisticsAlgorithm for details relating QuantileComputer classes.
56
57template <class AccumType, class DataIterator, class MaskIterator = const Bool*,
58 class WeightsIterator = DataIterator>
59class ClassicalStatistics : public StatisticsAlgorithm<CASA_STATP> {
61
62 public:
64
65 // copy semantics
67
69
70 // copy semantics
72
73 // Clone this instance
75
76 // get the algorithm that this object uses for computing stats
78
79 // <group>
80 // In the following group of methods, if the size of the composite dataset
81 // is smaller than <src>binningThreshholdSizeBytes</src>, the composite
82 // dataset will be (perhaps partially) sorted and persisted in memory during
83 // the call. In that case, and if <src>persistSortedArray</src> is True,
84 // this sorted array will remain in memory after the call and will be used
85 // on subsequent calls of this method when
86 // <src>binningThreshholdSizeBytes</src> is greater than the size of the
87 // composite dataset. If <src>persistSortedArray</src> is False, the sorted
88 // array will not be stored after this call completes and so any subsequent
89 // calls for which the dataset size is less than
90 // <src>binningThreshholdSizeBytes</src>, the dataset will be sorted from
91 // scratch. Values which are not included due to non-unity strides, are not
92 // included in any specified ranges, are masked, or have associated weights
93 // of zero are not considered as dataset members for quantile computations.
94 // If one has a priori information regarding the number of points (npts)
95 // and/or the minimum and maximum values of the data set, these can be
96 // supplied to improve performance. Note however, that if these values are
97 // not correct, the resulting median and/or quantile values will also not be
98 // correct (although see the following notes regarding max/min). Note that
99 // if this object has already had getStatistics() called, and the min and
100 // max were calculated, there is no need to pass these values in as they
101 // have been stored internally and used (although passing them in shouldn't
102 // hurt anything). If provided, npts, the number of points falling in the
103 // specified ranges which are not masked and have weights > 0, should be
104 // exactly correct. <src>min</src> can be less than the true minimum, and
105 // <src>max</src> can be greater than the True maximum, but for best
106 // performance, these should be as close to the actual min and max as
107 // possible. In order for quantile computations to occur over multiple
108 // datasets, all datasets must be available. This means that if
109 // setCalculateAsAdded() was previously called by passing in a value of
110 // True, these methods will throw an exception as the previous call
111 // indicates that there is no guarantee that all datasets will be available.
112 // If one uses a data provider (by having called setDataProvider()), then
113 // this should not be an issue.
114
115 // Get the median of the distribution. For a dataset with an odd number of
116 // good points, the median is just the value at index int(N/2) in the
117 // equivalent sorted dataset, where N is the number of points. For a dataset
118 // with an even number of points, the median is the mean of the values at
119 // indices int(N/2)-1 and int(N/2) in the sorted dataset. <src>nBins</src>
120 // is the number of bins, per histogram, to use to bin the data. More
121 // bins decrease the likelihood that multiple passes of the data set will be
122 // necessary, but also increase the amount of memory used. If nBins is set
123 // to less than 1,000, it is automatically increased to 1,000; there should
124 // be no reason to ever set nBins to be this small.
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,
129 Bool persistSortedArray = False, uInt nBins = 10000);
130
131 // If one needs to compute both the median and quantile values, it is better
132 // to call getMedianAndQuantiles() rather than getMedian() and
133 // getQuantiles() separately, as the first will scan large data sets fewer
134 // times than calling the separate methods. The return value is the median;
135 // the quantiles are returned in the <src>quantiles</src> map. Values in the
136 // <src>fractions</src> set represent the locations in the CDF and should be
137 // between 0 and 1, exclusive.
138 virtual AccumType getMedianAndQuantiles(std::map<Double, AccumType>& quantiles,
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,
144 Bool persistSortedArray = False, uInt nBins = 10000);
145
146 // get the median of the absolute deviation about the median of the data.
147 virtual AccumType getMedianAbsDevMed(std::shared_ptr<uInt64> knownNpts = nullptr,
148 std::shared_ptr<AccumType> knownMin = nullptr,
149 std::shared_ptr<AccumType> knownMax = nullptr,
150 uInt binningThreshholdSizeBytes = 4096 * 4096,
151 Bool persistSortedArray = False, uInt nBins = 10000);
152
153 // Get the specified quantiles. <src>fractions</src> must be between 0 and
154 // 1, noninclusive.
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,
160 Bool persistSortedArray = False,
161 uInt nBins = 10000);
162 // </group>
163
164 // <group>
165 // scan the dataset(s) that have been added, and find the min and max. This
166 // method may be called even if setStatsToCaclulate has been called and MAX
167 // and MIN has been excluded. If setCalculateAsAdded(True) has previously
168 // been called after this object has been (re)initialized, an exception will
169 // be thrown. The second version also determines npts in the same scan.
170 virtual void getMinMax(AccumType& mymin, AccumType& mymax);
171
172 virtual void getMinMaxNpts(uInt64& npts, AccumType& mymin, AccumType& mymax);
173 // </group>
174
175 // scan the dataset(s) that have been added, and find the number of good
176 // points. This method may be called even if setStatsToCaclulate has been
177 // called and NPTS has been excluded. If setCalculateAsAdded(True) has
178 // previously been called after this object has been (re)initialized, an
179 // exception will be thrown.
180 virtual uInt64 getNPts();
181
182 // see base class description
183 virtual std::pair<Int64, Int64> getStatisticIndex(StatisticsData::STATS stat);
184
185 // reset object to initial state. Clears all private fields including data,
186 // accumulators, etc.
187 virtual void reset();
188
189 // Should statistics be updated with calls to addData or should they only be
190 // calculated upon calls to getStatistics() etc? Beware that calling this
191 // will automatically reinitialize the object, so that it will contain no
192 // references to data et al. after this method has been called.
193 virtual void setCalculateAsAdded(Bool c);
194
195 // An exception will be thrown if setCalculateAsAdded(True) has been called.
197
198 // Allow derived objects to set the quantile computer object. API developers
199 // shouldn't need to call this, unless they are writing derived classes
200 // of ClassicalStatistics. Purposefully non-virtual. Derived classes should
201 // not implement.
203 _qComputer = qc;
204 }
205
206 virtual void setStatsToCalculate(std::set<StatisticsData::STATS>& stats);
207
208 protected:
209 // This constructor should be used by derived objects in order to set
210 // the proper quantile computer object
212
213 // <group>
214 // scan through the data set to determine the number of good (unmasked,
215 // weight > 0, within range) points. The first with no mask, no ranges, and
216 // no weights is trivial with npts = nr in this class, but is implemented
217 // here so that derived classes may override it.
218 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin, uInt64 nr,
219 uInt dataStride) const;
220
221 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
222 const DataRanges& ranges, Bool isInclude) const;
223
224 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
225 const MaskIterator& maskBegin, uInt maskStride) const;
226
227 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
228 const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
229 Bool isInclude) const;
230
231 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin,
232 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride) const;
233
234 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin,
235 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
236 const DataRanges& ranges, Bool isInclude) const;
237
238 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin,
239 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
240 const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
241 Bool isInclude) const;
242
243 virtual void _accumNpts(uInt64& npts, const DataIterator& dataBegin,
244 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
245 const MaskIterator& maskBegin, uInt maskStride) const;
246 // </group>
247
248 // <group>
249 inline void _accumulate(StatsData<AccumType>& stats, const AccumType& datum,
250 const LocationType& location);
251
252 inline void _accumulate(StatsData<AccumType>& stats, const AccumType& datum,
253 const AccumType& weight, const LocationType& location);
254 // </group>
255
256 void _addData();
257
259
260 Bool _getDoMaxMin() const { return _doMaxMin; }
261
263
264 virtual AccumType _getStatistic(StatisticsData::STATS stat);
265
267
268 // Retrieve stats structure. Allows derived classes to maintain their own
269 // StatsData structs.
271
272 virtual const StatsData<AccumType>& _getStatsData() const { return _statsData; }
273
274 // <group>
275 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
276 const DataIterator& dataBegin, uInt64 nr, uInt dataStride) const;
277
278 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
279 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
280 const DataRanges& ranges, Bool isInclude) const;
281
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;
285
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;
290
291 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
292 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
293 uInt64 nr, uInt dataStride) const;
294
295 virtual void _minMax(std::shared_ptr<AccumType>& mymin, std::shared_ptr<AccumType>& mymax,
296 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
297 uInt64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude) const;
298
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,
302 const DataRanges& ranges, Bool isInclude) const;
303
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;
307 // </group>
308
309 // <group>
310 // Sometimes we want the min, max, and npts all in one scan.
311 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
312 std::shared_ptr<AccumType>& mymax, const DataIterator& dataBegin,
313 uInt64 nr, uInt dataStride) const;
314
315 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
316 std::shared_ptr<AccumType>& mymax, const DataIterator& dataBegin,
317 uInt64 nr, uInt dataStride, const DataRanges& ranges,
318 Bool isInclude) const;
319
320 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
321 std::shared_ptr<AccumType>& mymax, const DataIterator& dataBegin,
322 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
323 uInt maskStride) const;
324
325 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
326 std::shared_ptr<AccumType>& mymax, const DataIterator& dataBegin,
327 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
328 uInt maskStride, const DataRanges& ranges, Bool isInclude) const;
329
330 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
331 std::shared_ptr<AccumType>& mymax, const DataIterator& dataBegin,
332 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride) const;
333
334 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
335 std::shared_ptr<AccumType>& mymax, const DataIterator& dataBegin,
336 const WeightsIterator& weightsBegin, uInt64 nr, uInt dataStride,
337 const DataRanges& ranges, Bool isInclude) const;
338
339 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
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;
344
345 virtual void _minMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymin,
346 std::shared_ptr<AccumType>& mymax, const DataIterator& dataBegin,
347 const WeightsIterator& weightBegin, uInt64 nr, uInt dataStride,
348 const MaskIterator& maskBegin, uInt maskStride) const;
349 // </group>
350
351 std::shared_ptr<StatisticsAlgorithmQuantileComputer<CASA_STATP>> _getQuantileComputer() {
352 return _qComputer;
353 }
354
355 // <group>
356 // no weights, no mask, no ranges
357 virtual void _unweightedStats(StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
358 const DataIterator& dataBegin, uInt64 nr, uInt dataStride);
359
360 // no weights, no mask
361 virtual void _unweightedStats(StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
362 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
363 const DataRanges& ranges, Bool isInclude);
364
365 virtual void _unweightedStats(StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
366 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
367 const MaskIterator& maskBegin, uInt maskStride);
368
369 virtual void _unweightedStats(StatsData<AccumType>& stats, uInt64& ngood, LocationType& location,
370 const DataIterator& dataBegin, uInt64 nr, uInt dataStride,
371 const MaskIterator& maskBegin, uInt maskStride,
372 const DataRanges& ranges, Bool isInclude);
373
374 // </group>
375 virtual void _updateDataProviderMaxMin(const StatsData<AccumType>& threadStats);
376
377 // <group>
378 // has weights, but no mask, no ranges
379 virtual void _weightedStats(StatsData<AccumType>& stats, LocationType& location,
380 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
381 uInt64 nr, uInt dataStride);
382
383 virtual void _weightedStats(StatsData<AccumType>& stats, LocationType& location,
384 const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
385 uInt64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude);
386
387 virtual void _weightedStats(StatsData<AccumType>& stats, LocationType& location,
388 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
389 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
390 uInt maskStride);
391
392 virtual void _weightedStats(StatsData<AccumType>& stats, LocationType& location,
393 const DataIterator& dataBegin, const WeightsIterator& weightBegin,
394 uInt64 nr, uInt dataStride, const MaskIterator& maskBegin,
395 uInt maskStride, const DataRanges& ranges, Bool isInclude);
396 // </group>
397
398 private:
401
402 std::shared_ptr<ClassicalQuantileComputer<CASA_STATP>> _qComputer{};
403
404 void _computeMinMax(std::shared_ptr<AccumType>& mymax, std::shared_ptr<AccumType>& mymin,
405 DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter,
406 uInt64 dataCount, const ChunkType& chunk);
407
408 void _computeMinMaxNpts(uInt64& npts, std::shared_ptr<AccumType>& mymax,
409 std::shared_ptr<AccumType>& mymin, DataIterator dataIter,
410 MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount,
411 const ChunkType& chunk);
412
413 void _computeNpts(uInt64& npts, DataIterator dataIter, MaskIterator maskIter,
414 WeightsIterator weightsIter, uInt64 dataCount, const ChunkType& chunk);
415
417 DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter,
418 uInt64 count, const ChunkType& chunk);
419
420 // scan dataset(s) to find min and max
421 void _doMinMax(AccumType& vmin, AccumType& vmax);
422
423 uInt64 _doMinMaxNpts(AccumType& vmin, AccumType& vmax);
424
426
427 // for quantile computations, if necessary, determines npts, min, max to
428 // send to quantile calculator methods
429 void _doNptsMinMax(uInt64& mynpts, AccumType& mymin, AccumType& mymax,
430 std::shared_ptr<uInt64> knownNpts, std::shared_ptr<AccumType> knownMin,
431 std::shared_ptr<AccumType> knownMax);
432};
433
434} // namespace casacore
435
436#ifndef CASACORE_NO_AUTO_TEMPLATES
437#include <casacore/scimath/StatsFramework/ClassicalStatistics.tcc>
438#endif
439
440#endif
#define DataRanges
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 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...
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.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
std::pair< Int64, Int64 > LocationType
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
unsigned long long uInt64
Definition aipsxtype.h:37
holds information about a data chunk.