16 #ifndef QGSSTATISTICALSUMMARY_H 17 #define QGSSTATISTICALSUMMARY_H 22 #include "qgis_core.h" 51 CountMissing = 1 << 15,
63 FirstQuartile = 1 << 12,
64 ThirdQuartile = 1 << 13,
65 InterQuartileRange = 1 << 14,
68 All = Count | CountMissing | Sum | Mean | Median | StDev | Max | Min | Range | Minority | Majority | Variety | FirstQuartile | ThirdQuartile | InterQuartileRange | First | Last
93 void setStatistics( QgsStatisticalSummary::Statistics stats ) { mStatistics = stats; }
104 void calculate(
const QList<double> &values );
121 void addValue(
double value );
138 void addVariant(
const QVariant &value );
160 int count()
const {
return mCount; }
171 double sum()
const {
return mSum; }
177 double mean()
const {
return mMean; }
184 double median()
const {
return mMedian; }
190 double min()
const {
return mMin; }
196 double max()
const {
return mMax; }
202 double range()
const {
return std::isnan( mMax ) || std::isnan( mMin ) ? std::numeric_limits<double>::quiet_NaN() : mMax - mMin; }
210 double first()
const {
return mFirst; }
218 double last()
const {
return mLast; }
226 double stDev()
const {
return mStdev; }
241 int variety()
const {
return mValueCount.count(); }
286 double interQuartileRange()
const {
return std::isnan( mThirdQuartile ) || std::isnan( mFirstQuartile ) ? std::numeric_limits<double>::quiet_NaN() : mThirdQuartile - mFirstQuartile; }
303 Statistics mStatistics;
316 double mFirstQuartile;
317 double mThirdQuartile;
320 QMap< double, int > mValueCount;
321 QList< double > mValues;
322 bool mRequiresAllValueStorage =
false;
323 bool mRequiresHisto =
false;
326 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsStatisticalSummary::Statistics )
328 #endif // QGSSTATISTICALSUMMARY_H double max() const
Returns calculated maximum from values.
Statistic
Enumeration of flags that specify statistics to be calculated.
int variety() const
Returns variety of values.
double minority() const
Returns minority of values.
double range() const
Returns calculated range (difference between maximum and minimum values).
double median() const
Returns calculated median of values.
double sampleStDev() const
Returns sample standard deviation.
double firstQuartile() const
Returns the first quartile of the values.
double stDev() const
Returns population standard deviation.
double sum() const
Returns calculated sum of values.
double mean() const
Returns calculated mean of values.
double majority() const
Returns majority of values.
double first() const
Returns the first value obtained.
double interQuartileRange() const
Returns the inter quartile range of the values.
void setStatistics(QgsStatisticalSummary::Statistics stats)
Sets flags which specify which statistics will be calculated.
int countMissing() const
Returns the number of missing (null) values.
Statistics statistics() const
Returns flags which specify which statistics will be calculated.
double last() const
Returns the last value obtained.
int count() const
Returns calculated count of values.
double min() const
Returns calculated minimum from values.
Calculator for summary statistics for a list of doubles.
double thirdQuartile() const
Returns the third quartile of the values.