26#ifndef SCIMATH_STATISTICSUTILITIES_H
27#define SCIMATH_STATISTICSUTILITIES_H
29#include <casacore/casa/Exceptions/Error.h>
30#include <casacore/scimath/StatsFramework/StatisticsTypes.h>
31#include <casacore/scimath/StatsFramework/StatsHistogram.h>
32#include <casacore/casa/Utilities/DataType.h>
33#include <casacore/casa/aips.h>
36#include <casacore/casa/iosfwd.h>
44template <
class AccumType>
67 const AccumType& datum);
75 AccumType& wmean,
const AccumType& datum,
const AccumType& weight);
78 AccumType& sumsq,
const AccumType& datum);
82 AccumType& wmean, AccumType& wnvariance, AccumType& wsumsq,
83 const AccumType& datum,
const AccumType& weight);
89 template <
class LocationType>
95 template <
class LocationType,
class DataType>
101 template <
class LocationType>
103 AccumType&
mean, AccumType& nvariance, AccumType& sumsq,
111 template <
class LocationType>
115 template <
class LocationType>
126 const AccumType& datum,
const AccumType& center);
130 AccumType& wsumsq,
const AccumType& datum,
131 const AccumType& weight,
const AccumType& center);
135 template <
class LocationType>
141 template <
class LocationType>
145 const AccumType& datum,
const AccumType& weight,
154 typename DataRanges::const_iterator beginRange,
155 typename DataRanges::const_iterator endRange,
Bool isInclude);
160 const std::set<uInt64>& indices);
163 std::vector<BinCountArray>& bins, std::vector<std::shared_ptr<AccumType>>& sameVal,
164 std::vector<Bool>& allSame,
const std::unique_ptr<std::vector<BinCountArray>[]>& tBins,
165 const std::unique_ptr<std::vector<std::shared_ptr<AccumType>>[]>& tSameVal,
166 const std::unique_ptr<std::vector<Bool>[]>& tAllSame,
uInt nThreadsMax);
176 template <
class DataIterator,
class MaskIterator,
class WeightsIterator>
182 const static AccumType
TWO;
187#ifndef CASACORE_NO_AUTO_TEMPLATES
188#include <casacore/scimath/StatsFramework/StatisticsUtilities.tcc>
#define DataArray
Commonly used types in statistics framework.
#define CASA_STATD
because the template signature has become unwieldy
static void accumulate(Double &npts, AccumType &sum, AccumType &mean, const AccumType &datum)
accumulate values.
static void mergeResults(std::vector< BinCountArray > &bins, std::vector< std::shared_ptr< AccumType > > &sameVal, std::vector< Bool > &allSame, const std::unique_ptr< std::vector< BinCountArray >[]> &tBins, const std::unique_ptr< std::vector< std::shared_ptr< AccumType > >[]> &tSameVal, const std::unique_ptr< std::vector< Bool >[]> &tAllSame, uInt nThreadsMax)
static uInt nThreadsMax(const StatsDataProvider< CASA_STATP > *const dataProvider)
static Bool doMax(AccumType &datamax, LocationType &maxpos, Bool isFirst, const AccumType &datum, const LocationType &location)
return True if the max or min was updated, False otherwise.
static void accumulateSym(Double &npts, AccumType &nvariance, AccumType &sumsq, const AccumType &datum, const AccumType ¢er)
These versions are for symmetric accumulation about a specified center point.
static void waccumulateSym(Double &npts, AccumType &sumweights, AccumType &wnvariance, AccumType &wsumsq, const AccumType &datum, const AccumType &weight, const AccumType ¢er)
wsumsq is the weighted sum of squares, sum(w_i*x_i*x_i)
static StatsData< AccumType > combine(const std::vector< StatsData< AccumType > > &stats)
use two statistics sets to get the statistics set that would result in combining the two data sets us...
static void accumulateSym(Double &npts, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const LocationType &location, const AccumType ¢er)
maxpos and minpos refer to actual, not virtually created, data only.
static const AccumType TWO
static void waccumulate(Double &npts, AccumType &sumofweights, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const AccumType &weight, const LocationType &location)
static void waccumulate(Double &npts, AccumType &sumweights, AccumType &wsum, AccumType &wmean, AccumType &wnvariance, AccumType &wsumsq, const AccumType &datum, const AccumType &weight)
wsumsq is the weighted sum of squares, sum(w_i*x_i*x_i)
static void waccumulateSym(Double &npts, AccumType &sumofweights, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const AccumType &weight, const LocationType &location, const AccumType ¢er)
static std::map< uInt64, AccumType > indicesToValues(std::vector< AccumType > &myArray, const std::set< uInt64 > &indices)
The array can be changed by partially sorting it up to the largest index.
static void convertToAbsDevMedArray(DataArray &myArray, AccumType median)
convert in place by taking the absolute value of the difference of the std::vector and the median
static void accumulate(Double &npts, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, const AccumType &datum)
StatisticsUtilities()=delete
static Bool includeDatum(const AccumType &datum, typename DataRanges::const_iterator beginRange, typename DataRanges::const_iterator endRange, Bool isInclude)
static void waccumulate(Double &npts, AccumType &sumweights, AccumType &wsum, AccumType &wmean, const AccumType &datum, const AccumType &weight)
in order to optimize performance, no checking is done for the weight == 0 case callers should ensure ...
static void accumulate(Double &npts, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, DataType &datamin, DataType &datamax, LocationType &minpos, LocationType &maxpos, const DataType &datum, const LocationType &location)
static void accumulate(Double &npts, AccumType &sum, AccumType &mean, AccumType &nvariance, AccumType &sumsq, AccumType &datamin, AccumType &datamax, LocationType &minpos, LocationType &maxpos, const AccumType &datum, const LocationType &location)
The assignment operator of class LocationType should use copy, not reference, semantics.
static Bool doMin(AccumType &datamin, LocationType &minpos, Bool isFirst, const AccumType &datum, const LocationType &location)
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 mean(const LatticeExprNode &expr)
LatticeExprNode sum(const LatticeExprNode &expr)
std::pair< Int64, Int64 > LocationType
bool Bool
Define the standard types used by Casacore.
LatticeExprNode median(const LatticeExprNode &expr)