26#ifndef SCIMATH_FITTOHALFSTATISTICS_H
27#define SCIMATH_FITTOHALFSTATISTICS_H
29#include <casacore/casa/aips.h>
31#include <casacore/scimath/StatsFramework/ConstrainedRangeStatistics.h>
32#include <casacore/scimath/StatsFramework/FitToHalfStatisticsData.h>
50template <
class AccumType,
class DataIterator,
class MaskIterator =
const Bool*,
51 class WeightsIterator = DataIterator>
54 const static AccumType
TWO;
79 AccumType
getMedian(std::shared_ptr<uInt64> knownNpts =
nullptr,
80 std::shared_ptr<AccumType> knownMin =
nullptr,
81 std::shared_ptr<AccumType> knownMax =
nullptr,
82 uInt binningThreshholdSizeBytes = 4096 * 4096,
115 const std::set<Double>& fractions,
116 std::shared_ptr<uInt64> knownNpts =
nullptr,
117 std::shared_ptr<AccumType> knownMin =
nullptr,
118 std::shared_ptr<AccumType> knownMax =
nullptr,
119 uInt binningThreshholdSizeBytes = 4096 * 4096,
124 std::shared_ptr<AccumType> knownMin =
nullptr,
125 std::shared_ptr<AccumType> knownMax =
nullptr,
126 uInt binningThreshholdSizeBytes = 4096 * 4096,
131 std::map<Double, AccumType>
getQuantiles(
const std::set<Double>& fractions,
132 std::shared_ptr<uInt64> knownNpts =
nullptr,
133 std::shared_ptr<AccumType> knownMin =
nullptr,
134 std::shared_ptr<AccumType> knownMax =
nullptr,
135 uInt binningThreshholdSizeBytes = 4096 * 4096,
142 virtual void getMinMax(AccumType& mymin, AccumType& mymax);
176 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride);
180 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
184 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
185 const MaskIterator& maskBegin,
uInt maskStride);
188 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
189 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
198 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
uInt64 nr,
202 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
uInt64 nr,
206 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
uInt64 nr,
207 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride);
210 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
uInt64 nr,
211 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
227 std::shared_ptr<std::pair<AccumType, AccumType>>
_range;
231 void _getMinMax(std::shared_ptr<AccumType>& realMin, std::shared_ptr<AccumType>& realMax,
232 std::shared_ptr<AccumType> knownMin, std::shared_ptr<AccumType> knownMax);
242#ifndef CASACORE_NO_AUTO_TEMPLATES
243#include <casacore/scimath/StatsFramework/FitToHalfStatistics.tcc>
ConstrainedRangeStatistics()=delete
USE_DATA
which section of data to use, greater than or less than the center value
CENTER
choice of center point based on the corresponding statistics from the entire distribution of data,...
virtual StatsData< AccumType > _getStatistics()
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)
void _updateDataProviderMaxMin(const StatsData< AccumType > &threadStats)
virtual void getMinMax(AccumType &mymin, AccumType &mymax)
scan the dataset(s) that have been added, and find the min and max.
FitToHalfStatistics< CASA_STATP > & operator=(const FitToHalfStatistics< CASA_STATP > &other)
copy semantics
FitToHalfStatistics(const FitToHalfStatistics< CASA_STATP > &other)
copy semantics
virtual StatsData< AccumType > _getInitialStats() const
const StatsData< AccumType > & _getStatsData() const
static const AccumType TWO
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)
In the following group of methods, if the size of the composite dataset is smaller than binningThresh...
StatsData< AccumType > & _getStatsData()
Retrieve stats structure.
FitToHalfStatisticsData::CENTER _centerType
virtual StatisticsAlgorithm< CASA_STATP > * clone() const
Clone this instance.
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.
std::shared_ptr< AccumType > _realMin
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)
void _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude)
FitToHalfStatistics(FitToHalfStatisticsData::CENTER center=FitToHalfStatisticsData::CMEAN, FitToHalfStatisticsData::USE_DATA useData=FitToHalfStatisticsData::LE_CENTER, AccumType value=0)
value is only used if center=CVALUE
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
std::shared_ptr< AccumType > _realMax
these are the max and min for the real portion of the dataset
void _unweightedStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, uInt64 nr, uInt dataStride)
no weights, no mask, no ranges
virtual ~FitToHalfStatistics()
virtual void setStatsToCalculate(std::set< StatisticsData::STATS > &stats)
Override base class method by requiring mean to be computed in addition to what is added in stats if ...
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)
The median is just the center value, so none of the parameters to this method are used.
std::shared_ptr< std::pair< AccumType, AccumType > > _range
This is used for convenience and performance.
StatsData< AccumType > _statsData
virtual StatisticsData::ALGORITHM algorithm() const
get the algorithm that this object uses for computing stats
void _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride)
void _unweightedStats(StatsData< AccumType > &stats, uInt64 &ngood, LocationType &location, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride)
uInt64 getNPts()
scan the dataset(s) that have been added, and find the number of good points.
void _getMinMax(std::shared_ptr< AccumType > &realMin, std::shared_ptr< AccumType > &realMax, std::shared_ptr< AccumType > knownMin, std::shared_ptr< AccumType > knownMax)
get the min max of the entire (real + virtual) data set.
void setCalculateAsAdded(Bool c)
This class does not allow statistics to be calculated as datasets are added, so an exception will be ...
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 void reset()
reset object to initial state.
void _getRealMinMax(AccumType &realMin, AccumType &realMax)
get the min/max of the real portion only of the dataset
void _weightedStats(StatsData< AccumType > &stats, LocationType &location, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride)
has weights, but no mask, no ranges
Base class of statistics algorithm class hierarchy.
ALGORITHM
implemented algorithms
For temporary backward namespace compatibility, use casa as alias for casacore.
std::pair< Int64, Int64 > LocationType
bool Bool
Define the standard types used by Casacore.
NewDelAllocator< T > NewDelAllocator< T >::value
unsigned long long uInt64