27 #ifndef SCIMATH_STATSALGORITHM_H 28 #define SCIMATH_STATSALGORITHM_H 30 #include <casacore/casa/aips.h> 31 #include <casacore/casa/Exceptions/Error.h> 32 #include <casacore/casa/Utilities/CountedPtr.h> 33 #include <casacore/scimath/Mathematics/StatsDataProvider.h> 34 #include <casacore/scimath/Mathematics/StatisticsData.h> 35 #include <casacore/scimath/Mathematics/StatisticsTypes.h> 42 #define CASA_STATD template <class AccumType, class DataIterator, class MaskIterator, class WeightsIterator> 43 #define CASA_STATP AccumType, DataIterator, MaskIterator, WeightsIterator 104 template <
class AccumType,
class DataIterator,
class MaskIterator=const Bool *,
class WeightsIterator=DataIterator>
135 const DataIterator& first,
uInt nr,
141 const DataIterator& first,
const MaskIterator& maskFirst,
146 const DataIterator& first,
const MaskIterator& maskFirst,
153 const DataIterator& first,
const WeightsIterator& weightFirst,
158 const DataIterator& first,
const WeightsIterator& weightFirst,
164 const DataIterator& first,
const WeightsIterator& weightFirst,
165 const MaskIterator& maskFirst,
uInt nr,
uInt dataStride=1,
171 const DataIterator& first,
const WeightsIterator& weightFirst,
172 const MaskIterator& maskFirst,
uInt nr,
const DataRanges& dataRanges,
192 std::map<Double, AccumType>& quantileToValue,
const std::set<Double>& quantiles,
195 uInt binningThreshholdSizeBytes=4096*4096,
Bool persistSortedArray=
False,
203 uInt binningThreshholdSizeBytes=4096*4096,
Bool persistSortedArray=
False,
210 uInt binningThreshholdSizeBytes=4096*4096,
218 uInt binningThreshholdSizeBytes=4096*4096,
Bool persistSortedArray=
False,
236 virtual void reset();
245 const DataIterator& first,
uInt nr,
251 const DataIterator& first,
const MaskIterator& maskFirst,
257 const DataIterator& first,
const MaskIterator& maskFirst,
264 const DataIterator& first,
const WeightsIterator& weightFirst,
270 const DataIterator& first,
const WeightsIterator& weightFirst,
277 const DataIterator& first,
const WeightsIterator& weightFirst,
278 const MaskIterator& maskFirst,
uInt nr,
uInt dataStride=1,
284 const DataIterator& first,
const WeightsIterator& weightFirst,
285 const MaskIterator& maskFirst,
uInt nr,
const DataRanges& dataRanges,
363 vector<AccumType>& myArray,
const std::set<uInt64>& indices
388 #ifndef CASACORE_NO_AUTO_TEMPLATES 389 #include <casacore/scimath/Mathematics/StatisticsAlgorithm.tcc> virtual void setStatsToCalculate(std::set< StatisticsData::STATS > &stats)
Provide guidance to algorithms by specifying a priori which statistics the caller would like calculat...
std::vector< AccumType > & _getSortedArray()
StatisticsAlgorithm< CASA_STATP > & operator=(const StatisticsAlgorithm< CASA_STATP > &other)
use copy semantics
virtual void _addData()
Allows derived classes to do things after data is set or added.
const std::map< uInt, uInt > & _getMaskStrides() const
std::map< uInt, DataRanges > _dataRanges
virtual void addData(const DataIterator &first, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False)
Add a dataset to an existing set of datasets on which statistics are to be calculated.
std::map< uInt, WeightsIterator > _weights
maps data to weights
virtual StatsData< AccumType > _getStatistics()=0
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
std::map< uInt, MaskIterator > _masks
maps data to masks
unsigned long long uInt64
virtual AccumType getStatistic(StatisticsData::STATS stat)
get the value of the specified statistic
vector< uInt > _dataStrides
virtual ~StatisticsAlgorithm()
virtual AccumType _getStatistic(StatisticsData::STATS stat)=0
vector< AccumType > _sortedArray
virtual 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)=0
The return value is the median; the quantiles are returned in the quantileToValue map...
virtual AccumType getMedianAbsDevMed(CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)=0
get the median of the absolute deviation about the median of the data.
void _setSortedArray(const vector< AccumType > &v)
std::map< uInt, Bool > _isIncludeRanges
ALGORITHM
implemented algorithms
const std::map< uInt, MaskIterator > _getMasks() const
Referenced counted pointer for constant data.
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
virtual void setDataProvider(StatsDataProvider< CASA_STATP > *dataProvider)
instead of settng and adding data "by hand", set the data provider that will provide all the data set...
StatsDataProvider< CASA_STATP > * _getDataProvider()
vector< DataIterator > _data
virtual StatsData< AccumType > getStatistics()
std::map< uInt, uInt > _maskStrides
StatsDataProvider< CASA_STATP > * _dataProvider
virtual StatisticsAlgorithm< CASA_STATP > * clone() const =0
Clone this instance.
const vector< DataIterator > & _getData() const
virtual StatisticsData::ALGORITHM algorithm() const =0
get the algorithm that this object uses for computing stats
#define DataRanges
Commonly used types in statistics framework.
bool Bool
Define the standard types used by Casacore.
virtual const std::set< StatisticsData::STATS > & _getUnsupportedStatistics() const
void _throwIfDataProviderDefined() const
const std::map< uInt, DataRanges > & _getRanges() const
const std::set< StatisticsData::STATS > _getStatsToCalculate() const
const std::map< uInt, WeightsIterator > & _getWeights() const
const StatsDataProvider< CASA_STATP > * _getDataProvider() const
virtual AccumType getMedian(CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)=0
const vector< uInt > & _getDataStrides() const
virtual std::pair< Int64, Int64 > getStatisticIndex(StatisticsData::STATS stat)=0
certain statistics such as max and min have locations in the dataset associated with them...
void deleteSortedArray()
delete any (partially) sorted array
virtual void setData(const DataIterator &first, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False)
setdata() clears any current datasets or data provider and then adds the specified data set as the fi...
std::set< StatisticsData::STATS > _statsToCalculate
std::set< StatisticsData::STATS > _unsupportedStats
*static std::map< uInt64, AccumType > _valuesFromArray(vector< AccumType > &myArray, const std::set< uInt64 > &indices)
The array can be changed by paritally sorting it up to the largest index.
AccumType getQuantile(Double quantile, CountedPtr< uInt64 > knownNpts=NULL, CountedPtr< AccumType > knownMin=NULL, CountedPtr< AccumType > knownMax=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)
const std::map< uInt, Bool > & _getIsIncludeRanges() const
const vector< Int64 > & _getCounts() const
virtual void reset()
reset this object by clearing data.
Base class of statistics algorithm class hierarchy.
this file contains all the compiler specific defines
virtual std::map< Double, AccumType > getQuantiles(const std::set< Double > &quantiles, CountedPtr< uInt64 > npts=NULL, CountedPtr< AccumType > min=NULL, CountedPtr< AccumType > max=NULL, uInt binningThreshholdSizeBytes=4096 *4096, Bool persistSortedArray=False, uInt64 nBins=10000)=0
get a map of quantiles to values.