casacore
ConstrainedRangeStatistics.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: aips2-request@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 //# $Id: Array.h 21545 2015-01-22 19:36:35Z gervandiepen $
26 
27 #ifndef SCIMATH_CONSTRAINEDRANGESTATISTICS_H
28 #define SCIMATH_CONSTRAINEDRANGESTATISTICS_H
29 
30 #include <casacore/casa/aips.h>
31 
32 #include <casacore/scimath/Mathematics/ClassicalStatistics.h>
33 
34 #include <set>
35 #include <vector>
36 #include <utility>
37 
38 namespace casacore {
39 
40 // Abstract base class for statistics algorithms which are characterized by
41 // a range of good values. The range is usually calculated dynamically based on the entire distribution.
42 
43 template <class AccumType, class DataIterator, class MaskIterator=const Bool*, class WeightsIterator=DataIterator>
45  : public ClassicalStatistics<CASA_STATP> {
46 public:
47 
49 
50  // copy semantics
53  );
54 
55  // <group>
56  // In the following group of methods, if the size of the composite dataset
57  // is smaller than
58  // <src>binningThreshholdSizeBytes</src>, the composite dataset
59  // will be (perhaps partially) sorted and persisted in memory during the
60  // call. In that case, and if <src>persistSortedArray</src> is True, this
61  // sorted array will remain in memory after the call and will be used on
62  // subsequent calls of this method when <src>binningThreshholdSizeBytes</src>
63  // is greater than the size of the composite dataset. If
64  // <src>persistSortedArray</src> is False, the sorted array will not be
65  // stored after this call completes and so any subsequent calls for which the
66  // dataset size is less than <src>binningThreshholdSizeBytes</src>, the
67  // dataset will be sorted from scratch. Values which are not included due to
68  // non-unity strides, are not included in any specified ranges, are masked,
69  // or have associated weights of zero are not considered as dataset members
70  // for quantile computations.
71  // If one has a priori information regarding
72  // the number of points (npts) and/or the minimum and maximum values of the data
73  // set, these can be supplied to improve performance. Note however, that if these
74  // values are not correct, the resulting median
75  // and/or quantile values will also not be correct (although see the following notes regarding
76  // max/min). Note that if this object has already had getStatistics()
77  // called, and the min and max were calculated, there is no need to pass these values in
78  // as they have been stored internally and used (although passing them in shouldn't hurt
79  // anything). If provided, npts, the number of points falling in the specified ranges which are
80  // not masked and have weights > 0, should be exactly correct. <src>min</src> can be less than
81  // the true minimum, and <src>max</src> can be greater than the True maximum, but for best
82  // performance, these should be as close to the actual min and max as possible.
83  // In order for quantile computations to occur over multiple datasets, all datasets
84  // must be available. This means that if setCalculateAsAdded()
85  // was previously called by passing in a value of True, these methods will throw
86  // an exception as the previous call indicates that there is no guarantee that
87  // all datasets will be available. If one uses a data provider (by having called
88  // setDataProvider()), then this should not be an issue.
89 
90  // get the median of the distribution.
91  // For a dataset with an odd number of good points, the median is just the value
92  // at index int(N/2) in the equivalent sorted dataset, where N is the number of points.
93  // For a dataset with an even number of points, the median is the mean of the values at
94  // indices int(N/2)-1 and int(N/2) in the sorted dataset.
95  AccumType getMedian(
96  CountedPtr<uInt64> knownNpts=NULL, CountedPtr<AccumType> knownMin=NULL,
97  CountedPtr<AccumType> knownMax=NULL, uInt binningThreshholdSizeBytes=4096*4096,
98  Bool persistSortedArray=False, uInt64 nBins=10000
99  );
100 
101  // get the median of the absolute deviation about the median of the data.
102  AccumType getMedianAbsDevMed(
103  CountedPtr<uInt64> knownNpts=NULL,
104  CountedPtr<AccumType> knownMin=NULL, CountedPtr<AccumType> knownMax=NULL,
105  uInt binningThreshholdSizeBytes=4096*4096, Bool persistSortedArray=False,
106  uInt64 nBins=10000
107  );
108 
109  // If one needs to compute both the median and quantile values, it is better to call
110  // getMedianAndQuantiles() rather than getMedian() and getQuantiles() seperately, as the
111  // first will scan large data sets fewer times than calling the seperate methods.
112  // The return value is the median; the quantiles are returned in the <src>quantileToValue</src> map.
113  AccumType getMedianAndQuantiles(
114  std::map<Double, AccumType>& quantileToValue, const std::set<Double>& quantiles,
115  CountedPtr<uInt64> knownNpts=NULL, CountedPtr<AccumType> knownMin=NULL,
116  CountedPtr<AccumType> knownMax=NULL,
117  uInt binningThreshholdSizeBytes=4096*4096, Bool persistSortedArray=False,
118  uInt64 nBins=10000
119  );
120 
121  // Get the specified quantiles. <src>quantiles</src> must be between 0 and 1,
122  // noninclusive.
123  std::map<Double, AccumType> getQuantiles(
124  const std::set<Double>& quantiles, CountedPtr<uInt64> knownNpts=NULL,
125  CountedPtr<AccumType> knownMin=NULL, CountedPtr<AccumType> knownMax=NULL,
126  uInt binningThreshholdSizeBytes=4096*4096, Bool persistSortedArray=False,
127  uInt64 nBins=10000
128  );
129  // </group>
130 
131  // get the min and max of the data set
132  virtual void getMinMax(AccumType& mymin, AccumType& mymax);
133 
134  // scan the dataset(s) that have been added, and find the number of good points.
135  // This method may be called even if setStatsToCaclulate has been called and
136  // NPTS has been excluded. If setCalculateAsAdded(True) has previously been
137  // called after this object has been (re)initialized, an exception will be thrown.
138  virtual uInt64 getNPts();
139 
140  // see base class description
141  std::pair<Int64, Int64> getStatisticIndex(StatisticsData::STATS stat);
142 
143  // reset object to initial state. Clears all private fields including data,
144  // accumulators, global range. It does not affect the fence factor (_f), which was
145  // set at object construction.
146  virtual void reset();
147 
148 protected:
150 
151  // <group>
152  // scan through the data set to determine the number of good (unmasked, weight > 0,
153  // within range) points. The first with no mask, no
154  // ranges, and no weights is trivial with npts = nr in this class, but is implemented here
155  // so that derived classes may override it.
156  inline void _accumNpts(
157  uInt64& npts,
158  const DataIterator& dataStart, Int64 nr, uInt dataStride
159  ) const;
160 
161  void _accumNpts(
162  uInt64& npts,
163  const DataIterator& dataStart, Int64 nr, uInt dataStride,
164  const DataRanges& ranges, Bool isInclude
165  ) const;
166 
167  void _accumNpts(
168  uInt64& npts,
169  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
170  const MaskIterator& maskBegin, uInt maskStride
171  ) const;
172 
173  void _accumNpts(
174  uInt64& npts,
175  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
176  const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
177  Bool isInclude
178  ) const;
179 
180  void _accumNpts(
181  uInt64& npts,
182  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
183  Int64 nr, uInt dataStride
184  ) const;
185 
186  void _accumNpts(
187  uInt64& npts,
188  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
189  Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude
190  ) const;
191 
192  void _accumNpts(
193  uInt64& npts,
194  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
195  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
196  const DataRanges& ranges, Bool isInclude
197  ) const;
198 
199  void _accumNpts(
200  uInt64& npts,
201  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
202  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride
203  ) const;
204  // </group>
205 
206  virtual void _findBins(
207  vector<vector<uInt64> >& binCounts,
208  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
209  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
210  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc,
211  const vector<AccumType>& maxLimit
212  ) const;
213 
214  virtual void _findBins(
215  vector<vector<uInt64> >& binCounts,
216  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
217  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
218  const DataRanges& ranges, Bool isInclude,
219  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
220  ) const;
221 
222  virtual void _findBins(
223  vector<vector<uInt64> >& binCounts,
224  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
225  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
226  const MaskIterator& maskBegin, uInt maskStride,
227  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
228  ) const;
229 
230  virtual void _findBins(
231  vector<vector<uInt64> >& binCounts,
232  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
233  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
234  const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
235  Bool isInclude,
236  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
237  ) const;
238 
239  virtual void _findBins(
240  vector<vector<uInt64> >& binCounts,
241  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
242  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
243  Int64 nr, uInt dataStride,
244  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
245  ) const ;
246 
247  virtual void _findBins(
248  vector<vector<uInt64> >& binCounts,
249  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
250  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
251  Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude,
252  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
253  ) const;
254 
255  virtual void _findBins(
256  vector<vector<uInt64> >& binCounts,
257  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
258  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
259  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
260  const DataRanges& ranges, Bool isInclude,
261  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
262  ) const;
263 
264  virtual void _findBins(
265  vector<vector<uInt64> >& binCounts,
266  vector<CountedPtr<AccumType> >& sameVal, vector<Bool>& allSame,
267  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
268  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
269  const vector<typename StatisticsUtilities<AccumType>::BinDesc>& binDesc, const vector<AccumType>& maxLimit
270  ) const;
271  // </group>
272 
273  AccumType _getStatistic(StatisticsData::STATS stat);
274 
276 
277  inline Bool _isInRange(const AccumType& datum) const;
278 
279  // <group>
280  virtual void _minMax(
282  const DataIterator& dataBegin, Int64 nr, uInt dataStride
283  ) const;
284 
285  virtual void _minMax(
287  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
288  const DataRanges& ranges, Bool isInclude
289  ) const;
290 
291  virtual void _minMax(
293  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
294  const MaskIterator& maskBegin, uInt maskStride
295  ) const;
296 
297  virtual void _minMax(
299  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
300  const MaskIterator& maskBegin, uInt maskStride, const DataRanges& ranges,
301  Bool isInclude
302  ) const;
303 
304  virtual void _minMax(
306  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
307  Int64 nr, uInt dataStride
308  ) const;
309 
310  virtual void _minMax(
312  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
313  Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude
314  ) const;
315 
316  virtual void _minMax(
318  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
319  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
320  const DataRanges& ranges, Bool isInclude
321  ) const;
322 
323  virtual void _minMax(
325  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
326  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride
327  ) const;
328  // </group>
329 
330  //<group>
331  // populate an unsorted array with valid data. If <src>includeLimits</src> is defined,
332  // then restrict values that are entered in the array to those limits (inclusive of the
333  // minimum, exclusive of the maximum). <src>maxCount</src> and <src>currentCount</src> are
334  // used only if <src>includeLimits</src> is defined. In this case, the method will return
335  // when currentCount == maxCount, thus avoiding scanning remaining data unnecessarily.
336 
337  // no weights, no mask, no ranges
338  void _populateArray(
339  vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr, uInt dataStride
340  ) const;
341 
342  // ranges
343  void _populateArray(
344  vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
345  uInt dataStride, const DataRanges& ranges, Bool isInclude
346  ) const;
347 
348  void _populateArray(
349  vector<AccumType>& ary, const DataIterator& dataBegin,
350  Int64 nr, uInt dataStride, const MaskIterator& maskBegin,
351  uInt maskStride
352  ) const;
353 
354  // mask and ranges
355  void _populateArray(
356  vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
357  uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
358  const DataRanges& ranges, Bool isInclude
359  ) const;
360 
361  // weights
362  void _populateArray(
363  vector<AccumType>& ary, const DataIterator& dataBegin,
364  const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride
365  ) const;
366 
367  // weights and ranges
368  void _populateArray(
369  vector<AccumType>& ary, const DataIterator& dataBegin,
370  const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
371  const DataRanges& ranges, Bool isInclude
372  ) const;
373 
374  // weights and mask
375  void _populateArray(
376  vector<AccumType>& ary, const DataIterator& dataBegin,
377  const WeightsIterator& weightBegin, Int64 nr, uInt dataStride,
378  const MaskIterator& maskBegin, uInt maskStride
379  ) const;
380 
381  // weights, mask, ranges
382  void _populateArray(
383  vector<AccumType>& ary, const DataIterator& dataBegin, const WeightsIterator& weightBegin,
384  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
385  const DataRanges& ranges, Bool isInclude
386  ) const;
387 
388  // no weights, no mask, no ranges
389  virtual void _populateArrays(
390  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin, Int64 nr, uInt dataStride,
391  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
392  ) const;
393 
394  // ranges
395  virtual void _populateArrays(
396  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin, Int64 nr,
397  uInt dataStride, const DataRanges& ranges, Bool isInclude,
398  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
399  ) const;
400 
401  virtual void _populateArrays(
402  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin,
403  Int64 nr, uInt dataStride, const MaskIterator& maskBegin,
404  uInt maskStride,
405  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
406  ) const;
407 
408  // mask and ranges
409  virtual void _populateArrays(
410  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin, Int64 nr,
411  uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
412  const DataRanges& ranges, Bool isInclude,
413  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
414  ) const;
415 
416  // weights
417  virtual void _populateArrays(
418  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin,
419  const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
420  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
421  ) const;
422 
423  // weights and ranges
424  virtual void _populateArrays(
425  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin,
426  const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
427  const DataRanges& ranges, Bool isInclude,
428  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
429  ) const;
430 
431  // weights and mask
432  virtual void _populateArrays(
433  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin,
434  const WeightsIterator& weightBegin, Int64 nr, uInt dataStride,
435  const MaskIterator& maskBegin, uInt maskStride,
436  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
437  ) const;
438 
439  // weights, mask, ranges
440  virtual void _populateArrays(
441  vector<vector<AccumType> >& arys, uInt& currentCount, const DataIterator& dataBegin, const WeightsIterator& weightBegin,
442  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
443  const DataRanges& ranges, Bool isInclude,
444  const vector<std::pair<AccumType, AccumType> > &includeLimits, uInt maxCount
445  ) const;
446  // </group>
447 
448  // <group>
449  // no weights, no mask, no ranges
451  vector<AccumType>& ary, const DataIterator& dataBegin,
452  Int64 nr, uInt dataStride, uInt maxElements
453  ) const;
454 
455  // ranges
457  vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
458  uInt dataStride, const DataRanges& ranges, Bool isInclude,
459  uInt maxElements
460  ) const;
461 
462  // mask
464  vector<AccumType>& ary, const DataIterator& dataBegin,
465  Int64 nr, uInt dataStride, const MaskIterator& maskBegin,
466  uInt maskStride, uInt maxElements
467  ) const;
468 
469  // mask and ranges
471  vector<AccumType>& ary, const DataIterator& dataBegin, Int64 nr,
472  uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
473  const DataRanges& ranges, Bool isInclude, uInt maxElements
474  ) const;
475 
476  // weights
478  vector<AccumType>& ary, const DataIterator& dataBegin,
479  const WeightsIterator& weightBegin, Int64 nr, uInt dataStride,
480  uInt maxElements
481  ) const;
482 
483  // weights and ranges
485  vector<AccumType>& ary, const DataIterator& dataBegin,
486  const WeightsIterator& weightsBegin, Int64 nr, uInt dataStride,
487  const DataRanges& ranges, Bool isInclude, uInt maxElements
488  ) const;
489 
490  // weights and mask
492  vector<AccumType>& ary, const DataIterator& dataBegin,
493  const WeightsIterator& weightBegin, Int64 nr,
494  uInt dataStride, const MaskIterator& maskBegin,
495  uInt maskStride, uInt maxElements
496  ) const;
497 
498  // weights, mask, ranges
500  vector<AccumType>& ary, const DataIterator& dataBegin, const WeightsIterator& weightBegin,
501  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
502  const DataRanges& ranges, Bool isInclude,
503  uInt maxElements
504  ) const;
505  // </group>
506 
507  inline void _setRange(CountedPtr<std::pair<AccumType, AccumType> > r) { this->_clearStats(); _range = r; }
508 
509  // derived classes need to implement how to set their respective range
510  virtual void _setRange() = 0;
511 
512  // <group>
513  // no weights, no mask, no ranges
514  void _unweightedStats(
515  uInt64& ngood, AccumType& mymin, AccumType& mymax,
516  Int64& minpos, Int64& maxpos,
517  const DataIterator& dataBegin, Int64 nr, uInt dataStride
518  );
519 
520  // no weights, no mask
521  void _unweightedStats(
522  uInt64& ngood, AccumType& mymin, AccumType& mymax,
523  Int64& minpos, Int64& maxpos,
524  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
525  const DataRanges& ranges, Bool isInclude
526  );
527 
528  void _unweightedStats(
529  uInt64& ngood, AccumType& mymin, AccumType& mymax,
530  Int64& minpos, Int64& maxpos,
531  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
532  const MaskIterator& maskBegin, uInt maskStride
533  );
534 
535  void _unweightedStats(
536  uInt64& ngood, AccumType& mymin, AccumType& mymax,
537  Int64& minpos, Int64& maxpos,
538  const DataIterator& dataBegin, Int64 nr, uInt dataStride,
539  const MaskIterator& maskBegin, uInt maskStride,
540  const DataRanges& ranges, Bool isInclude
541  );
542  // </group>
543 
544  // <group>
545  // has weights, but no mask, no ranges
546  void _weightedStats(
547  AccumType& mymin, AccumType& mymax,
548  Int64& minpos, Int64& maxpos,
549  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
550  Int64 nr, uInt dataStride
551  );
552 
553  void _weightedStats(
554  AccumType& mymin, AccumType& mymax,
555  Int64& minpos, Int64& maxpos,
556  const DataIterator& dataBegin, const WeightsIterator& weightsBegin,
557  Int64 nr, uInt dataStride, const DataRanges& ranges, Bool isInclude
558  );
559 
560  void _weightedStats(
561  AccumType& mymin, AccumType& mymax,
562  Int64& minpos, Int64& maxpos,
563  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
564  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride
565  );
566 
567  void _weightedStats(
568  AccumType& mymin, AccumType& mymax,
569  Int64& minpos, Int64& maxpos,
570  const DataIterator& dataBegin, const WeightsIterator& weightBegin,
571  Int64 nr, uInt dataStride, const MaskIterator& maskBegin, uInt maskStride,
572  const DataRanges& ranges, Bool isInclude
573  );
574  // </group>
575 
576 private:
579 
580 };
581 
582 }
583 
584 #ifndef CASACORE_NO_AUTO_TEMPLATES
585 #include <casacore/scimath/Mathematics/ConstrainedRangeStatistics.tcc>
586 #endif
587 
588 #endif
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
AccumType getMedian(CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)
In the following group of methods, if the size of the composite dataset is smaller than binningThresh...
void _setRange(CountedPtr< std::pair< AccumType, AccumType > > r)
CASA_STATP _getStatistic(StatisticsData::STATS stat)
virtual void _minMax(CountedPtr< CASA_STATP > &mymin, CountedPtr< CASA_STATP > &mymax, const DataIterator &dataBegin, Int64 nr, uInt dataStride) const
StatsData< CASA_STATP > _getStatistics()
virtual void _weightedStats(CASA_STATP &mymin, CASA_STATP &mymax, Int64 &minpos, Int64 &maxpos, const DataIterator &dataBegin, const DataIterator &weightsBegin, Int64 nr, uInt dataStride)
has weights, but no mask, no ranges
unsigned long long uInt64
Definition: aipsxtype.h:39
void _accumNpts(uInt64 &npts, const DataIterator &dataStart, Int64 nr, uInt dataStride) const
scan through the data set to determine the number of good (unmasked, weight > 0, within range) points...
Class to calculate statistics in a "classical" sense, ie using accumulators with no special filtering...
virtual void _unweightedStats(uInt64 &ngood, CASA_STATP &mymin, CASA_STATP &mymax, Int64 &minpos, Int64 &maxpos, const DataIterator &dataBegin, Int64 nr, uInt dataStride)
no weights, no mask, no ranges
std::map< Double, AccumType > getQuantiles(const std::set< Double > &quantiles, CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)
Get the specified quantiles.
CountedPtr< std::pair< AccumType, AccumType > > _range
AccumType getMedianAbsDevMed(CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)
get the median of the absolute deviation about the median of the data.
virtual uInt64 getNPts()
scan the dataset(s) that have been added, and find the number of good points.
Referenced counted pointer for constant data.
Definition: CountedPtr.h:86
ConstrainedRangeStatistics< CASA_STATP > & operator=(const ConstrainedRangeStatistics< CASA_STATP > &other)
copy semantics
#define DataRanges
Commonly used types in statistics framework.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
virtual Bool _populateTestArray(vector< CASA_STATP > &ary, const DataIterator &dataBegin, Int64 nr, uInt dataStride, uInt maxElements) const
no weights, no mask, no ranges
virtual void reset()
reset object to initial state.
Abstract base class for statistics algorithms which are characterized by a range of good values...
const Bool False
Definition: aipstype.h:41
Bool _isInRange(const AccumType &datum) const
std::pair< Int64, Int64 > getStatisticIndex(StatisticsData::STATS stat)
see base class description
AccumType getMedianAndQuantiles(std::map< Double, AccumType > &quantileToValue, const std::set< Double > &quantiles, CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)
If one needs to compute both the median and quantile values, it is better to call getMedianAndQuantil...
virtual void _populateArray(vector< CASA_STATP > &ary, const DataIterator &dataBegin, Int64 nr, uInt dataStride) const
populate an unsorted array with valid data.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
virtual void _populateArrays(vector< vector< CASA_STATP > > &arys, uInt &currentCount, const DataIterator &dataBegin, Int64 nr, uInt dataStride, const vector< std::pair< CASA_STATP, CASA_STATP > > &includeLimits, uInt maxCount) const
Create a vector of unsorted arrays, one array for each bin defined by includeLimits.
virtual void getMinMax(AccumType &mymin, AccumType &mymax)
get the min and max of the data set
virtual void _findBins(vector< vector< uInt64 > > &binCounts, vector< CountedPtr< AccumType > > &sameVal, vector< Bool > &allSame, const DataIterator &dataBegin, Int64 nr, uInt dataStride, const vector< typename StatisticsUtilities< AccumType >::BinDesc > &binDesc, const vector< AccumType > &maxLimit) const
unsigned int uInt
Definition: aipstype.h:48
description of a regularly spaced bins with the first bin having lower limit of minLimit and having n...