Calculator for summary statistics for a list of doubles.
More...
#include <qgsstatisticalsummary.h>
|
enum | Statistic {
Count = 1 << 0
, CountMissing = 1 << 15
, Sum = 1 << 1
, Mean = 1 << 2
,
Median = 1 << 3
, StDev = 1 << 4
, StDevSample = 1 << 5
, Min = 1 << 6
,
Max = 1 << 7
, Range = 1 << 8
, Minority = 1 << 9
, Majority = 1 << 10
,
Variety = 1 << 11
, FirstQuartile = 1 << 12
, ThirdQuartile = 1 << 13
, InterQuartileRange = 1 << 14
,
First = 1 << 16
, Last = 1 << 17
, All = Count | CountMissing | Sum | Mean | Median | StDev | Max | Min | Range | Minority | Majority | Variety | FirstQuartile | ThirdQuartile | InterQuartileRange | First | Last
} |
| Enumeration of flags that specify statistics to be calculated. More...
|
|
Calculator for summary statistics for a list of doubles.
Statistics are calculated by calling calculate() and passing a list of doubles. The individual statistics can then be retrieved using the associated methods. Note that not all statistics are calculated by default. Statistics which require slower computations are only calculated by specifying the statistic in the constructor or via setStatistics().
- Since
- QGIS 2.9
Definition at line 43 of file qgsstatisticalsummary.h.
◆ Statistic
Enumeration of flags that specify statistics to be calculated.
Enumerator |
---|
Count | Count.
|
CountMissing | Number of missing (null) values.
|
Sum | Sum of values.
|
Mean | Mean of values.
|
Median | Median of values.
|
StDev | Standard deviation of values.
|
StDevSample | Sample standard deviation of values.
|
Min | Min of values.
|
Max | Max of values.
|
Range | Range of values (max - min)
|
Minority | Minority of values.
|
Majority | Majority of values.
|
Variety | Variety (count of distinct) values.
|
FirstQuartile | First quartile.
|
ThirdQuartile | Third quartile.
|
InterQuartileRange | Inter quartile range (IQR)
|
First | First value (since QGIS 3.6)
|
Last | Last value (since QGIS 3.6)
|
All | |
Definition at line 48 of file qgsstatisticalsummary.h.
◆ QgsStatisticalSummary()
◆ ~QgsStatisticalSummary()
virtual QgsStatisticalSummary::~QgsStatisticalSummary |
( |
| ) |
|
|
virtualdefault |
◆ addValue()
void QgsStatisticalSummary::addValue |
( |
double |
value | ) |
|
Adds a single value to the statistics calculation.
Calling this method allows values to be added to the calculation one at a time. For large quantities of values this may be more efficient then first adding all the values to a list and calling calculate().
- Parameters
-
- Note
- call reset() before adding the first value using this method to clear the results from any previous calculations
-
finalize() must be called after adding the final value and before retrieving calculated statistics.
- See also
- calculate()
-
addVariant()
-
finalize()
- Since
- QGIS 2.16
Definition at line 85 of file qgsstatisticalsummary.cpp.
◆ addVariant()
void QgsStatisticalSummary::addVariant |
( |
const QVariant & |
value | ) |
|
Adds a single value to the statistics calculation.
Calling this method allows values to be added to the calculation one at a time. For large quantities of values this may be more efficient then first adding all the values to a list and calling calculate().
- Parameters
-
value | variant containing to add. Non-numeric values are treated as null. |
- Note
- call reset() before adding the first value using this method to clear the results from any previous calculations
-
finalize() must be called after adding the final value and before retrieving calculated statistics.
- See also
- addValue()
-
calculate()
-
finalize()
- Since
- QGIS 2.16
Definition at line 102 of file qgsstatisticalsummary.cpp.
◆ calculate()
void QgsStatisticalSummary::calculate |
( |
const QList< double > & |
values | ) |
|
◆ count()
int QgsStatisticalSummary::count |
( |
| ) |
const |
|
inline |
◆ countMissing()
int QgsStatisticalSummary::countMissing |
( |
| ) |
const |
|
inline |
◆ displayName()
◆ finalize()
void QgsStatisticalSummary::finalize |
( |
| ) |
|
◆ first()
double QgsStatisticalSummary::first |
( |
| ) |
const |
|
inline |
Returns the first value obtained.
A NaN value may be returned if no values were encountered.
- See also
- last()
- Since
- QGIS 3.6
Definition at line 210 of file qgsstatisticalsummary.h.
◆ firstQuartile()
double QgsStatisticalSummary::firstQuartile |
( |
| ) |
const |
|
inline |
◆ interQuartileRange()
double QgsStatisticalSummary::interQuartileRange |
( |
| ) |
const |
|
inline |
Returns the inter quartile range of the values.
The quartiles are calculated using the "Tukey's hinges" method. A NaN value may be returned if the IQR cannot be calculated.
- See also
- firstQuartile
-
thirdQuartile
Definition at line 286 of file qgsstatisticalsummary.h.
◆ last()
double QgsStatisticalSummary::last |
( |
| ) |
const |
|
inline |
Returns the last value obtained.
A NaN value may be returned if no values were encountered.
- See also
- first()
- Since
- QGIS 3.6
Definition at line 218 of file qgsstatisticalsummary.h.
◆ majority()
double QgsStatisticalSummary::majority |
( |
| ) |
const |
|
inline |
Returns majority of values.
The majority is the value with most occurrences in the list. This is only calculated if Statistic::Majority has been specified in the constructor or via setStatistics. If multiple values match, return the first value relative to the initial values order. A NaN value may be returned if the minority cannot be calculated.
- See also
- minority
Definition at line 259 of file qgsstatisticalsummary.h.
◆ max()
double QgsStatisticalSummary::max |
( |
| ) |
const |
|
inline |
Returns calculated maximum from values.
A NaN value may be returned if the maximum cannot be calculated.
Definition at line 196 of file qgsstatisticalsummary.h.
◆ mean()
double QgsStatisticalSummary::mean |
( |
| ) |
const |
|
inline |
Returns calculated mean of values.
A NaN value may be returned if the mean cannot be calculated.
Definition at line 177 of file qgsstatisticalsummary.h.
◆ median()
double QgsStatisticalSummary::median |
( |
| ) |
const |
|
inline |
Returns calculated median of values.
This is only calculated if Statistic::Median has been specified in the constructor or via setStatistics. A NaN value may be returned if the median cannot be calculated.
Definition at line 184 of file qgsstatisticalsummary.h.
◆ min()
double QgsStatisticalSummary::min |
( |
| ) |
const |
|
inline |
Returns calculated minimum from values.
A NaN value may be returned if the minimum cannot be calculated.
Definition at line 190 of file qgsstatisticalsummary.h.
◆ minority()
double QgsStatisticalSummary::minority |
( |
| ) |
const |
|
inline |
Returns minority of values.
The minority is the value with least occurrences in the list. This is only calculated if Statistic::Minority has been specified in the constructor or via setStatistics. If multiple values match, return the first value relative to the initial values order. A NaN value may be returned if the minority cannot be calculated.
- See also
- majority
Definition at line 250 of file qgsstatisticalsummary.h.
◆ range()
double QgsStatisticalSummary::range |
( |
| ) |
const |
|
inline |
Returns calculated range (difference between maximum and minimum values).
A NaN value may be returned if the range cannot be calculated.
Definition at line 202 of file qgsstatisticalsummary.h.
◆ reset()
void QgsStatisticalSummary::reset |
( |
| ) |
|
◆ sampleStDev()
double QgsStatisticalSummary::sampleStDev |
( |
| ) |
const |
|
inline |
Returns sample standard deviation.
This is only calculated if Statistic::StDev has been specified in the constructor or via setStatistics. A NaN value may be returned if the standard deviation cannot be calculated.
- See also
- stDev
Definition at line 234 of file qgsstatisticalsummary.h.
◆ setStatistics()
void QgsStatisticalSummary::setStatistics |
( |
QgsStatisticalSummary::Statistics |
stats | ) |
|
Sets flags which specify which statistics will be calculated.
Some statistics are always calculated (e.g., sum, min and max).
- Parameters
-
stats | flags for statistics to calculate |
- See also
- statistics
Definition at line 34 of file qgsstatisticalsummary.cpp.
◆ shortName()
◆ statistic()
Returns the value of a specified statistic.
- Parameters
-
- Returns
- calculated value of statistic. A NaN value may be returned for invalid statistics.
Definition at line 252 of file qgsstatisticalsummary.cpp.
◆ statistics()
Statistics QgsStatisticalSummary::statistics |
( |
| ) |
const |
|
inline |
Returns flags which specify which statistics will be calculated.
Some statistics are always calculated (e.g., sum, min and max).
- See also
- setStatistics
Definition at line 85 of file qgsstatisticalsummary.h.
◆ stDev()
double QgsStatisticalSummary::stDev |
( |
| ) |
const |
|
inline |
Returns population standard deviation.
This is only calculated if Statistic::StDev has been specified in the constructor or via setStatistics. A NaN value may be returned if the standard deviation cannot be calculated.
- See also
- sampleStDev
Definition at line 226 of file qgsstatisticalsummary.h.
◆ sum()
double QgsStatisticalSummary::sum |
( |
| ) |
const |
|
inline |
◆ thirdQuartile()
double QgsStatisticalSummary::thirdQuartile |
( |
| ) |
const |
|
inline |
◆ variety()
int QgsStatisticalSummary::variety |
( |
| ) |
const |
|
inline |
Returns variety of values.
The variety is the count of unique values from the list. This is only calculated if Statistic::Variety has been specified in the constructor or via setStatistics.
Definition at line 241 of file qgsstatisticalsummary.h.
The documentation for this class was generated from the following files: