26#ifndef SCIMATH_BIWEIGHTSTATISTICS_H
27#define SCIMATH_BIWEIGHTSTATISTICS_H
29#include <casacore/casa/aips.h>
31#include <casacore/scimath/StatsFramework/ClassicalStatistics.h>
117template <
class AccumType,
class DataIterator,
class MaskIterator =
const Bool*,
118 class WeightsIterator = DataIterator>
139 virtual AccumType
getMedian(std::shared_ptr<uInt64> knownNpts =
nullptr,
140 std::shared_ptr<AccumType> knownMin =
nullptr,
141 std::shared_ptr<AccumType> knownMax =
nullptr,
142 uInt binningThreshholdSizeBytes = 4096 * 4096,
146 const std::set<Double>& quantiles,
147 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,
154 std::shared_ptr<AccumType> knownMin =
nullptr,
155 std::shared_ptr<AccumType> knownMax =
nullptr,
156 uInt binningThreshholdSizeBytes = 4096 * 4096,
159 virtual std::map<Double, AccumType>
getQuantiles(
const std::set<Double>& quantiles,
160 std::shared_ptr<uInt64> npts =
nullptr,
161 std::shared_ptr<AccumType>
min =
nullptr,
162 std::shared_ptr<AccumType>
max =
nullptr,
163 uInt binningThreshholdSizeBytes = 4096 * 4096,
198 std::pair<AccumType, AccumType>
_range{};
207 AccumType& ww_4u2, DataIterator dataIter, MaskIterator maskIter,
208 WeightsIterator weightsIter,
uInt64 dataCount,
212 MaskIterator maskIter, WeightsIterator weightsIter,
uInt64 dataCount,
216 MaskIterator maskIter, WeightsIterator weightsIter,
uInt64 dataCount,
231 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride)
const;
234 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
238 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
239 const MaskIterator& maskBegin,
uInt maskStride)
const;
242 const DataIterator& dataBegin,
uInt64 nr,
uInt dataStride,
243 const MaskIterator& maskBegin,
uInt maskStride,
247 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
251 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
253 Bool isInclude)
const;
256 const DataIterator& dataBegin,
const WeightsIterator& weightsBegin,
257 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
261 const DataIterator& dataBegin,
const WeightsIterator& weightBegin,
262 uInt64 nr,
uInt dataStride,
const MaskIterator& maskBegin,
263 uInt maskStride)
const;
270 uInt dataStride)
const;
276 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride)
const;
279 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
282 void _locationSums(AccumType& sxw2, AccumType& sw2,
const DataIterator& dataBegin,
283 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride)
const;
285 void _locationSums(AccumType& sxw2, AccumType& sw2,
const DataIterator& dataBegin,
286 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
289 void _locationSums(AccumType& sxw2, AccumType& sw2,
const DataIterator& dataBegin,
290 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
291 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
292 Bool isInclude)
const;
294 void _locationSums(AccumType& sxw2, AccumType& sw2,
const DataIterator& dataBegin,
295 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
296 const MaskIterator& maskBegin,
uInt maskStride)
const;
302 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
uInt64 nr,
303 uInt dataStride)
const;
305 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
uInt64 nr,
308 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
uInt64 nr,
309 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride)
const;
311 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
uInt64 nr,
312 uInt dataStride,
const MaskIterator& maskBegin,
uInt maskStride,
315 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
316 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride)
const;
318 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
319 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
322 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
323 const WeightsIterator& weightsBegin,
uInt64 nr,
uInt dataStride,
324 const MaskIterator& maskBegin,
uInt maskStride,
const DataRanges& ranges,
325 Bool isInclude)
const;
327 void _scaleSums(AccumType& sx_M2w4, AccumType& ww_4u2,
const DataIterator& dataBegin,
328 const WeightsIterator& weightBegin,
uInt64 nr,
uInt dataStride,
329 const MaskIterator& maskBegin,
uInt maskStride)
const;
335#ifndef CASACORE_NO_AUTO_TEMPLATES
336#include <casacore/scimath/StatsFramework/BiweightStatistics.tcc>
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
void _computeLocationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const typename StatisticsDataset< CASA_STATP >::ChunkData &chunk)
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
virtual ~BiweightStatistics()
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
sxw2 = sum(x_i*(1 - u_i^2)^2) sw2 = sum((1-u_i^2)^2)
uInt64 _npts
_npts is the number of points computed using ClassicalStatistics
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
virtual AccumType getMedianAndQuantiles(std::map< Double, AccumType > &quantileToValue, const std::set< Double > &quantiles, 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)
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
sx_M2w4 = sum((x_i - _location)^2 * (1 - u_i^2)^4) = sum((x_i - _location)^2 * w_i^4) ww_4u2 = sum((1...
virtual std::map< Double, AccumType > getQuantiles(const std::set< Double > &quantiles, std::shared_ptr< uInt64 > npts=nullptr, std::shared_ptr< AccumType > min=nullptr, std::shared_ptr< AccumType > max=nullptr, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt nBins=10000)
virtual void setStatsToCalculate(std::set< StatisticsData::STATS > &stats)
Provide guidance to algorithms by specifying a priori which statistics the caller would like calculat...
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)
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
virtual void setCalculateAsAdded(Bool c)
If c is True, an exception is thrown; this algorithm does not support computing stats as data are add...
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
virtual void reset()
reset object to initial state.
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const DataRanges &ranges, Bool isInclude) const
virtual StatisticsAlgorithm< CASA_STATP > * clone() const
Clone this instance.
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
void _computeScaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const typename StatisticsDataset< CASA_STATP >::ChunkData &chunk) const
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride) const
virtual StatisticsData::ALGORITHM algorithm() const
get the algorithm that this object uses for computing stats
void _locationAndScaleSums(AccumType &sxw2, AccumType &sw2, AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride) const
sxw2 = sum(x_i*(1 - u_i^2)^2) sw2 = sum((1-u_i^2)^2) sx_M2w4 = sum((x_i - _location)^2 * (1 - u_i^2)^...
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
std::pair< AccumType, AccumType > _range
virtual StatsData< AccumType > _getStatistics()
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, const WeightsIterator &weightsBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
virtual std::pair< Int64, Int64 > getStatisticIndex(StatisticsData::STATS stat)
see base class description
static const AccumType FOUR
because the compiler gets confused if these aren't explicitly typed
BiweightStatistics(Int maxNiter=3, Double c=6.0)
void _computeLocationSums(AccumType &sxw2, AccumType &sw2, DataIterator dataIter, MaskIterator maskIter, WeightsIterator weightsIter, uInt64 dataCount, const typename StatisticsDataset< CASA_STATP >::ChunkData &chunk)
BiweightStatistics< CASA_STATP > & operator=(const BiweightStatistics< CASA_STATP > &other)
copy semantics
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride, const DataRanges &ranges, Bool isInclude) const
void _locationSums(AccumType &sxw2, AccumType &sw2, const DataIterator &dataBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
BiweightStatistics(const BiweightStatistics< CASA_STATP > &other)
copy semantics
void _doLocationAndScale()
static const AccumType FIVE
void _scaleSums(AccumType &sx_M2w4, AccumType &ww_4u2, const DataIterator &dataBegin, const WeightsIterator &weightBegin, uInt64 nr, uInt dataStride, const MaskIterator &maskBegin, uInt maskStride) const
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)
these statistics are not supported.
Int getNiter() const
returns the number of iterations performed to compute the current location and scale values
Base class of statistics algorithm class hierarchy.
ALGORITHM
implemented algorithms
For temporary backward namespace compatibility, use casa as alias for casacore.
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
bool Bool
Define the standard types used by Casacore.
unsigned long long uInt64
holds information about a data chunk.