Class to calculate statistics using the so-called fit to half algorithm. More...
#include <FitToHalfStatistics.h>
Public Member Functions | |
FitToHalfStatistics (FitToHalfStatisticsData::CENTER center=FitToHalfStatisticsData::CMEAN, FitToHalfStatisticsData::USE_DATA useData=FitToHalfStatisticsData::LE_CENTER, AccumType value=0) | |
value is only used if center =CVALUE | |
virtual | ~FitToHalfStatistics () |
FitToHalfStatistics< CASA_STATP > & | operator= (const FitToHalfStatistics< CASA_STATP > &other) |
copy semantics | |
virtual StatisticsData::ALGORITHM | algorithm () const |
get the algorithm that this object uses for computing stats | |
AccumType | getMedian (CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000) |
The median is just the center value, so none of the parameters to this method are used. | |
AccumType | getMedianAndQuantiles (std::map< Double, AccumType > &quantiles, const std::set< Double > &fractions, 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 binningThreshholdSizeBytes , the composite dataset will be (perhaps partially) sorted and persisted in memory during the call. | |
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. | |
std::map< Double, AccumType > | getQuantiles (const std::set< Double > &fractions, 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. | |
virtual void | getMinMax (AccumType &mymin, AccumType &mymax) |
scan the dataset(s) that have been added, and find the min and max. | |
uInt64 | getNPts () |
scan the dataset(s) that have been added, and find the number of good points. | |
virtual void | reset () |
reset object to initial state. | |
void | setCalculateAsAdded (Bool c) |
This class does not allow statistics to be calculated as datasets are added, so an exception will be thrown if c is True. | |
Static Public Attributes | |
static const AccumType | TWO |
Protected Member Functions | |
virtual void | _clearData () |
virtual StatsData< AccumType > | _getInitialStats () const |
StatsData< AccumType > | _getStatistics () |
StatsData< AccumType > & | _getStatsData () |
retreive stats structure. | |
const StatsData< AccumType > & | _getStatsData () const |
void | _unweightedStats (StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, Int64 nr, uInt dataStride) |
no weights, no mask, no ranges | |
void | _unweightedStats (StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, Int64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) |
no weights, no mask | |
void | _unweightedStats (StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, Int64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) |
void | _unweightedStats (StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, Int64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) |
void | _updateDataProviderMaxMin (const StatsData< AccumType > &threadStats) |
void | _weightedStats (StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, Int64 nr, uInt dataStride) |
has weights, but no mask, no ranges | |
void | _weightedStats (StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, Int64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) |
void | _weightedStats (StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightBegin, Int64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) |
void | _weightedStats (StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightBegin, Int64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) |
Private Member Functions | |
void | _getRealMinMax (CountedPtr< AccumType > &realMin, CountedPtr< AccumType > &realMax, CountedPtr< AccumType > knownMin, CountedPtr< AccumType > knownMax) |
void | _setRange () |
Private Attributes | |
FitToHalfStatisticsData::CENTER | _centerType |
Bool | _useLower |
AccumType | _centerValue |
StatsData< AccumType > | _statsData |
Bool | _doMedAbsDevMed |
Bool | _rangeIsSet |
CountedPtr< AccumType > | _realMax |
these are the max and min for the real portion of the dataset | |
CountedPtr< AccumType > | _realMin |
Class to calculate statistics using the so-called fit to half algorithm.
In this algorithm, a center value is specified, and only points greater or equal or less or equal this value are included. Furthermore, each of the included points is reflected about the center value, and these virtual points are added to the included points and the union of sets of included real points and virtual points are used for computing statistics. The specified center point is therefore the mean and median of the resulting distribution, and the total number of points is exactly twice the number of real data points that are included.
Definition at line 47 of file FitToHalfStatistics.h.
casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::FitToHalfStatistics | ( | FitToHalfStatisticsData::CENTER | center = FitToHalfStatisticsData::CMEAN , |
|
FitToHalfStatisticsData::USE_DATA | useData = FitToHalfStatisticsData::LE_CENTER , |
|||
AccumType | value = 0 | |||
) |
value
is only used if center
=CVALUE
virtual casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::~FitToHalfStatistics | ( | ) | [virtual] |
virtual void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_clearData | ( | ) | [protected, virtual] |
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
virtual StatsData<AccumType> casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_getInitialStats | ( | ) | const [protected, virtual] |
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_getRealMinMax | ( | CountedPtr< AccumType > & | realMin, | |
CountedPtr< AccumType > & | realMax, | |||
CountedPtr< AccumType > | knownMin, | |||
CountedPtr< AccumType > | knownMax | |||
) | [private] |
StatsData<AccumType> casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_getStatistics | ( | ) | [protected, virtual] |
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
const StatsData<AccumType>& casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_getStatsData | ( | ) | const [inline, protected, virtual] |
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
Definition at line 164 of file FitToHalfStatistics.h.
References casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_statsData.
StatsData<AccumType>& casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_getStatsData | ( | ) | [inline, protected, virtual] |
retreive stats structure.
Allows derived classes to maintain their own StatsData structs.
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
Definition at line 162 of file FitToHalfStatistics.h.
References casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_statsData.
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_setRange | ( | ) | [private] |
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_unweightedStats | ( | StatsData< AccumType > & | stats, | |
uInt64 & | ngood, | |||
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
Int64 | nr, | |||
uInt | dataStride, | |||
const MaskIterator & | maskBegin, | |||
uInt | maskStride, | |||
const DataRanges & | ranges, | |||
Bool | isInclude | |||
) | [protected] |
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_unweightedStats | ( | StatsData< AccumType > & | stats, | |
uInt64 & | ngood, | |||
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
Int64 | nr, | |||
uInt | dataStride, | |||
const MaskIterator & | maskBegin, | |||
uInt | maskStride | |||
) | [protected] |
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_unweightedStats | ( | StatsData< AccumType > & | stats, | |
uInt64 & | ngood, | |||
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
Int64 | nr, | |||
uInt | dataStride, | |||
const DataRanges & | ranges, | |||
Bool | isInclude | |||
) | [protected] |
no weights, no mask
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_unweightedStats | ( | StatsData< AccumType > & | stats, | |
uInt64 & | ngood, | |||
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
Int64 | nr, | |||
uInt | dataStride | |||
) | [protected] |
no weights, no mask, no ranges
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_updateDataProviderMaxMin | ( | const StatsData< AccumType > & | threadStats | ) | [protected] |
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_weightedStats | ( | StatsData< AccumType > & | stats, | |
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
const WeightsIterator & | weightBegin, | |||
Int64 | nr, | |||
uInt | dataStride, | |||
const MaskIterator & | maskBegin, | |||
uInt | maskStride, | |||
const DataRanges & | ranges, | |||
Bool | isInclude | |||
) | [protected] |
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_weightedStats | ( | StatsData< AccumType > & | stats, | |
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
const WeightsIterator & | weightBegin, | |||
Int64 | nr, | |||
uInt | dataStride, | |||
const MaskIterator & | maskBegin, | |||
uInt | maskStride | |||
) | [protected] |
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_weightedStats | ( | StatsData< AccumType > & | stats, | |
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
const WeightsIterator & | weightsBegin, | |||
Int64 | nr, | |||
uInt | dataStride, | |||
const DataRanges & | ranges, | |||
Bool | isInclude | |||
) | [protected] |
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_weightedStats | ( | StatsData< AccumType > & | stats, | |
LocationType & | location, | |||
const DataIterator & | dataBegin, | |||
const WeightsIterator & | weightsBegin, | |||
Int64 | nr, | |||
uInt | dataStride | |||
) | [protected] |
has weights, but no mask, no ranges
virtual StatisticsData::ALGORITHM casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::algorithm | ( | ) | const [inline, virtual] |
get the algorithm that this object uses for computing stats
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
Definition at line 68 of file FitToHalfStatistics.h.
References casacore::StatisticsData::FITTOHALF.
AccumType casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::getMedian | ( | CountedPtr< uInt64 > | knownNpts = NULL , |
|
CountedPtr< AccumType > | knownMin = NULL , |
|||
CountedPtr< AccumType > | knownMax = NULL , |
|||
uInt | binningThreshholdSizeBytes = 4096 *4096 , |
|||
Bool | persistSortedArray = False , |
|||
uInt64 | nBins = 10000 | |||
) |
The median is just the center value, so none of the parameters to this method are used.
AccumType casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::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.
AccumType casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::getMedianAndQuantiles | ( | std::map< Double, AccumType > & | quantiles, | |
const std::set< Double > & | fractions, | |||
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 binningThreshholdSizeBytes
, the composite dataset will be (perhaps partially) sorted and persisted in memory during the call.
In that case, and if persistSortedArray
is True, this sorted array will remain in memory after the call and will be used on subsequent calls of this method when binningThreshholdSizeBytes
is greater than the size of the composite dataset. If persistSortedArray
is False, the sorted array will not be stored after this call completes and so any subsequent calls for which the dataset size is less than binningThreshholdSizeBytes
, the dataset will be sorted from scratch. Values which are not included due to non-unity strides, are not included in any specified ranges, are masked, or have associated weights of zero are not considered as dataset members for quantile computations. If one has a priori information regarding the number of points (npts) and/or the minimum and maximum values of the data set, these can be supplied to improve performance. Note however, that if these values are not correct, the resulting median and/or quantile values will also not be correct (although see the following notes regarding max/min). Note that if this object has already had getStatistics() called, and the min and max were calculated, there is no need to pass these values in as they have been stored internally and used (although passing them in shouldn't hurt anything). If provided, npts, the number of points falling in the specified ranges which are not masked and have weights > 0, should be exactly correct. min
can be less than the true minimum, and max
can be greater than the True maximum, but for best performance, these should be as close to the actual min and max as possible.
virtual void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::getMinMax | ( | AccumType & | mymin, | |
AccumType & | mymax | |||
) | [virtual] |
scan the dataset(s) that have been added, and find the min and max.
This method may be called even if setStatsToCaclulate has been called and MAX and MIN has been excluded.
uInt64 casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::getNPts | ( | ) | [virtual] |
scan the dataset(s) that have been added, and find the number of good points.
This method may be called even if setStatsToCaclulate has been called and NPTS has been excluded. If setCalculateAsAdded(True) has previously been called after this object has been (re)initialized, an exception will be thrown.
Reimplemented from casacore::ConstrainedRangeStatistics< CASA_STATP >.
std::map<Double, AccumType> casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::getQuantiles | ( | const std::set< Double > & | fractions, | |
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.
fractions
must be between 0 and 1, noninclusive.
FitToHalfStatistics<CASA_STATP>& casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::operator= | ( | const FitToHalfStatistics< CASA_STATP > & | other | ) |
copy semantics
Reimplemented from casacore::ConstrainedRangeStatistics< CASA_STATP >.
virtual void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::reset | ( | ) | [virtual] |
reset object to initial state.
Clears all private fields including data, accumulators, global range. It does not affect the fence factor (_f), which was set at object construction.
Reimplemented from casacore::ConstrainedRangeStatistics< CASA_STATP >.
void casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::setCalculateAsAdded | ( | Bool | c | ) | [virtual] |
This class does not allow statistics to be calculated as datasets are added, so an exception will be thrown if c
is True.
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
FitToHalfStatisticsData::CENTER casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_centerType [private] |
Definition at line 228 of file FitToHalfStatistics.h.
AccumType casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_centerValue [private] |
Definition at line 230 of file FitToHalfStatistics.h.
Bool casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_doMedAbsDevMed [private] |
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
Definition at line 232 of file FitToHalfStatistics.h.
Bool casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_rangeIsSet [private] |
Definition at line 232 of file FitToHalfStatistics.h.
CountedPtr<AccumType> casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_realMax [private] |
these are the max and min for the real portion of the dataset
Definition at line 234 of file FitToHalfStatistics.h.
CountedPtr<AccumType> casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_realMin [private] |
Definition at line 234 of file FitToHalfStatistics.h.
StatsData<AccumType> casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_statsData [private] |
Reimplemented from casacore::ClassicalStatistics< CASA_STATP >.
Definition at line 231 of file FitToHalfStatistics.h.
Referenced by casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_getStatsData().
Bool casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::_useLower [private] |
Definition at line 229 of file FitToHalfStatistics.h.
const AccumType casacore::FitToHalfStatistics< AccumType, DataIterator, MaskIterator, WeightsIterator >::TWO [static] |
Definition at line 51 of file FitToHalfStatistics.h.