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> 
   51    class AccumType, 
class DataIterator, 
class MaskIterator=
const Bool *,
 
   52    class WeightsIterator=DataIterator
 
   58    const static AccumType 
TWO;
 
   89        std::shared_ptr<uInt64> knownNpts=
nullptr,
 
   90        std::shared_ptr<AccumType> knownMin=
nullptr,
 
   91        std::shared_ptr<AccumType> knownMax=
nullptr,
 
   92        uInt binningThreshholdSizeBytes=4096*4096,
 
  126        std::map<Double, AccumType>& quantiles,
 
  127        const std::set<Double>& fractions,
 
  128        std::shared_ptr<uInt64> knownNpts=
nullptr,
 
  129        std::shared_ptr<AccumType> knownMin=
nullptr,
 
  130        std::shared_ptr<AccumType> knownMax=
nullptr,
 
  131        uInt binningThreshholdSizeBytes=4096*4096,
 
  137        std::shared_ptr<uInt64> knownNpts=
nullptr,
 
  138        std::shared_ptr<AccumType> knownMin=
nullptr,
 
  139        std::shared_ptr<AccumType> knownMax=
nullptr,
 
  140        uInt binningThreshholdSizeBytes=4096*4096,
 
  147        const std::set<Double>& fractions,
 
  148        std::shared_ptr<uInt64> knownNpts=
nullptr,
 
  149        std::shared_ptr<AccumType> knownMin=
nullptr,
 
  150        std::shared_ptr<AccumType> knownMax=
nullptr,
 
  151        uInt binningThreshholdSizeBytes=4096*4096,
 
  159    virtual void getMinMax(AccumType& mymin, AccumType& mymax);
 
  197        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride
 
  203        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  209        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  210        const MaskIterator& maskBegin, 
uInt maskStride
 
  215        const DataIterator& dataBegin, 
uInt64 nr, 
uInt dataStride,
 
  216        const MaskIterator& maskBegin, 
uInt maskStride,
 
  227        const DataIterator& dataBegin, 
const WeightsIterator& weightsBegin,
 
  233        const DataIterator& dataBegin, 
const WeightsIterator& weightsBegin,
 
  239        const DataIterator& dataBegin, 
const WeightsIterator& weightBegin,
 
  240        uInt64 nr, 
uInt dataStride, 
const MaskIterator& maskBegin,
 
  246        const DataIterator& dataBegin, 
const WeightsIterator& weightBegin,
 
  247        uInt64 nr, 
uInt dataStride, 
const MaskIterator& maskBegin,
 
  264    std::shared_ptr<std::pair<AccumType, AccumType>> 
_range;
 
  269        std::shared_ptr<AccumType>& realMin, std::shared_ptr<AccumType>& realMax,
 
  270        std::shared_ptr<AccumType> knownMin, std::shared_ptr<AccumType> knownMax
 
 
  282#ifndef CASACORE_NO_AUTO_TEMPLATES 
  283#include <casacore/scimath/StatsFramework/FitToHalfStatistics.tcc> 
Abstract base class for statistics algorithms which are characterized by a range of good values.
 
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,...
 
Class to calculate statistics using the so-called fit to half algorithm.
 
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)
 
void _setRange()
derived classes need to implement how to set their respective range
 
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
 
this file contains all the compiler specific defines
 
bool Bool
Define the standard types used by Casacore.
 
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
 
unsigned long long uInt64
 
std::pair< Int64, Int64 > LocationType