26#ifndef SCIMATH_STATISTICSALGORITHM_H
27#define SCIMATH_STATISTICSALGORITHM_H
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Exceptions/Error.h>
31#include <casacore/scimath/StatsFramework/StatsDataProvider.h>
32#include <casacore/scimath/StatsFramework/StatisticsData.h>
33#include <casacore/scimath/StatsFramework/StatisticsDataset.h>
34#include <casacore/scimath/StatsFramework/StatisticsTypes.h>
133template <
class AccumType,
class DataIterator,
class MaskIterator =
const Bool*,
134 class WeightsIterator = DataIterator>
179 void addData(
const DataIterator&
first,
const WeightsIterator& weightFirst,
180 const MaskIterator& maskFirst,
uInt nr,
uInt dataStride = 1,
183 void addData(
const DataIterator&
first,
const WeightsIterator& weightFirst,
184 const MaskIterator& maskFirst,
uInt nr,
const DataRanges& dataRanges,
186 uInt maskStride = 1);
192 virtual AccumType
getMedian(std::shared_ptr<uInt64> knownNpts =
nullptr,
193 std::shared_ptr<AccumType> knownMin =
nullptr,
194 std::shared_ptr<AccumType> knownMax =
nullptr,
195 uInt binningThreshholdSizeBytes = 4096 * 4096,
201 const std::set<Double>& quantiles,
202 std::shared_ptr<uInt64> knownNpts =
nullptr,
203 std::shared_ptr<AccumType> knownMin =
nullptr,
204 std::shared_ptr<AccumType> knownMax =
nullptr,
205 uInt binningThreshholdSizeBytes = 4096 * 4096,
210 std::shared_ptr<AccumType> knownMin =
nullptr,
211 std::shared_ptr<AccumType> knownMax =
nullptr,
212 uInt binningThreshholdSizeBytes = 4096 * 4096,
217 std::shared_ptr<AccumType> knownMin =
nullptr,
218 std::shared_ptr<AccumType> knownMax =
nullptr,
219 uInt binningThreshholdSizeBytes = 4096 * 4096,
223 virtual std::map<Double, AccumType>
getQuantiles(
const std::set<Double>& quantiles,
224 std::shared_ptr<uInt64> npts =
nullptr,
225 std::shared_ptr<AccumType>
min =
nullptr,
226 std::shared_ptr<AccumType>
max =
nullptr,
227 uInt binningThreshholdSizeBytes = 4096 * 4096,
229 uInt nBins = 10000) = 0;
276 void setData(
const DataIterator&
first,
const WeightsIterator& weightFirst,
277 const MaskIterator& maskFirst,
uInt nr,
uInt dataStride = 1,
280 void setData(
const DataIterator&
first,
const WeightsIterator& weightFirst,
281 const MaskIterator& maskFirst,
uInt nr,
const DataRanges& dataRanges,
283 uInt maskStride = 1);
346#ifndef CASACORE_NO_AUTO_TEMPLATES
347#include <casacore/scimath/StatsFramework/StatisticsAlgorithm.tcc>
virtual void reset()
reset this object by clearing data.
AccumType getQuantile(Double quantile, 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)
Purposefully not virtual.
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)=0
virtual StatsData< AccumType > _getStatistics()=0
void _resetExceptDataset()
void addData(const DataIterator &first, const WeightsIterator &weightFirst, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False)
std::set< StatisticsData::STATS > _statsToCalculate
void _setUnsupportedStatistics(const std::set< StatisticsData::STATS > &stats)
Derived classes should normally call this in their constructors, if applicable.
virtual void setDataProvider(StatsDataProvider< CASA_STATP > *dataProvider)
instead of setting and adding data "by hand", set the data provider that will provide all the data se...
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)=0
get the median of the absolute deviation about the median of the data.
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 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)=0
The return value is the median; the quantiles are returned in the quantileToValue map.
const std::set< StatisticsData::STATS > _getStatsToCalculate() const
AccumType getStatistic(StatisticsData::STATS stat)
get the value of the specified statistic.
virtual AccumType _getStatistic(StatisticsData::STATS stat)=0
virtual StatisticsData::ALGORITHM algorithm() const =0
get the algorithm that this object uses for computing stats
StatisticsAlgorithm(const StatisticsAlgorithm &other)
use copy semantics, except for the data provider which uses reference semantics
StatsData< AccumType > getStatistics()
Return statistics.
virtual StatisticsAlgorithm< CASA_STATP > * clone() const =0
Clone this instance.
std::set< StatisticsData::STATS > _unsupportedStats
const StatisticsDataset< CASA_STATP > & _getDataset() const
These methods are purposefully not virtual.
void setData(const DataIterator &first, const WeightsIterator &weightFirst, const MaskIterator &maskFirst, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=1)
virtual const std::set< StatisticsData::STATS > & _getUnsupportedStatistics() const
void setData(const DataIterator &first, const WeightsIterator &weightFirst, const MaskIterator &maskFirst, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=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)=0
get a map of quantiles to values.
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.
StatisticsAlgorithm & operator=(const StatisticsAlgorithm &other)
use copy semantics, except for the data provider which uses reference semantics
StatisticsDataset< CASA_STATP > _dataset
void setData(const DataIterator &first, const WeightsIterator &weightFirst, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False)
virtual LocationType getStatisticIndex(StatisticsData::STATS stat)=0
certain statistics such as max and min have locations in the dataset associated with them.
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...
void addData(const DataIterator &first, const MaskIterator &maskFirst, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=1)
StatisticsDataset< CASA_STATP > & _getDataset()
void addData(const DataIterator &first, const MaskIterator &maskFirst, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=1)
void addData(const DataIterator &first, const WeightsIterator &weightFirst, const MaskIterator &maskFirst, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=1)
virtual ~StatisticsAlgorithm()
void setData(const DataIterator &first, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False)
void setData(const DataIterator &first, const MaskIterator &maskFirst, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=1)
void setData(const DataIterator &first, const WeightsIterator &weightFirst, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False)
void addData(const DataIterator &first, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False)
virtual void _addData()
Allows derived classes to do things after data is set or added.
void addData(const DataIterator &first, const WeightsIterator &weightFirst, uInt nr, const DataRanges &dataRanges, Bool isInclude=True, uInt dataStride=1, Bool nrAccountsForStride=False)
void addData(const DataIterator &first, const WeightsIterator &weightFirst, const MaskIterator &maskFirst, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=1)
void setData(const DataIterator &first, const MaskIterator &maskFirst, uInt nr, uInt dataStride=1, Bool nrAccountsForStride=False, uInt maskStride=1)
ALGORITHM
implemented algorithms
Representation of a statistics dataset used in statistics framework calculatations.
Abstract base class which defines interface for providing "datasets" to the statistics framework in c...
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)
std::pair< Int64, Int64 > LocationType
bool Bool
Define the standard types used by Casacore.