28   : mStatistics( stats )
    40   mMin = std::numeric_limits<double>::max();
    41   mMax = -std::numeric_limits<double>::max();
    62   Q_FOREACH ( 
double value, values )
    74   mMin = std::min( mMin, value );
    75   mMax = std::max( mMax, value );
    78     mValueCount.insert( value, mValueCount.value( value, 0 ) + 1 );
    88   bool convertOk = 
false;
    89   if ( !value.isValid() || value.isNull() )
    93     double val = value.toDouble( &convertOk );
   105     mMin = std::numeric_limits<double>::quiet_NaN();
   106     mMax = std::numeric_limits<double>::quiet_NaN();
   107     mMean = std::numeric_limits<double>::quiet_NaN();
   108     mMedian = std::numeric_limits<double>::quiet_NaN();
   109     mStdev = std::numeric_limits<double>::quiet_NaN();
   110     mSampleStdev = std::numeric_limits<double>::quiet_NaN();
   111     mMinority = std::numeric_limits<double>::quiet_NaN();
   112     mMajority = std::numeric_limits<double>::quiet_NaN();
   113     mFirstQuartile = std::numeric_limits<double>::quiet_NaN();
   114     mThirdQuartile = std::numeric_limits<double>::quiet_NaN();
   118   mMean = mSum / mCount;
   122     double sumSquared = 0;
   123     Q_FOREACH ( 
double value, mValues )
   125       double diff = value - mMean;
   126       sumSquared += diff * diff;
   128     mStdev = std::pow( sumSquared / mValues.count(), 0.5 );
   129     mSampleStdev = std::pow( sumSquared / ( mValues.count() - 1 ), 0.5 );
   137     std::sort( mValues.begin(), mValues.end() );
   138     bool even = ( mCount % 2 ) < 1;
   141       mMedian = ( mValues[mCount / 2 - 1] + mValues[mCount / 2] ) / 2.0;
   145       mMedian = mValues[( mCount + 1 ) / 2 - 1];
   150        || mStatistics & QgsStatisticalSummary::InterQuartileRange )
   152     if ( ( mCount % 2 ) < 1 )
   154       int halfCount = mCount / 2;
   155       bool even = ( halfCount % 2 ) < 1;
   158         mFirstQuartile = ( mValues[halfCount / 2 - 1] + mValues[halfCount / 2] ) / 2.0;
   162         mFirstQuartile = mValues[( halfCount  + 1 ) / 2 - 1];
   167       int halfCount = mCount / 2 + 1;
   168       bool even = ( halfCount % 2 ) < 1;
   171         mFirstQuartile = ( mValues[halfCount / 2 - 1] + mValues[halfCount / 2] ) / 2.0;
   175         mFirstQuartile = mValues[( halfCount  + 1 ) / 2 - 1];
   181        || mStatistics & QgsStatisticalSummary::InterQuartileRange )
   183     if ( ( mCount % 2 ) < 1 )
   185       int halfCount = mCount / 2;
   186       bool even = ( halfCount % 2 ) < 1;
   189         mThirdQuartile = ( mValues[ halfCount + halfCount / 2 - 1] + mValues[ halfCount + halfCount / 2] ) / 2.0;
   193         mThirdQuartile = mValues[( halfCount + 1 ) / 2 - 1 + halfCount ];
   198       int halfCount = mCount / 2 + 1;
   199       bool even = ( halfCount % 2 ) < 1;
   202         mThirdQuartile = ( mValues[ halfCount + halfCount / 2 - 2 ] + mValues[ halfCount + halfCount / 2 - 1 ] ) / 2.0;
   206         mThirdQuartile = mValues[( halfCount + 1 ) / 2 - 2 + halfCount ];
   213     QList<int> valueCounts = mValueCount.values();
   214     std::sort( valueCounts.begin(), valueCounts.end() );
   217       mMinority = mValueCount.key( valueCounts.first() );
   219     if ( mStatistics & QgsStatisticalSummary::Majority )
   221       mMajority = mValueCount.key( valueCounts.last() );
   262       return mValueCount.count();
   264       return mFirstQuartile;
   266       return mThirdQuartile;
   268       return mThirdQuartile - mFirstQuartile;
   280       return QObject::tr( 
"Count" );
   282       return QObject::tr( 
"Count (missing)" );
   284       return QObject::tr( 
"Sum" );
   286       return QObject::tr( 
"Mean" );
   288       return QObject::tr( 
"Median" );
   290       return QObject::tr( 
"St dev (pop)" );
   292       return QObject::tr( 
"St dev (sample)" );
   294       return QObject::tr( 
"Minimum" );
   296       return QObject::tr( 
"Maximum" );
   298       return QObject::tr( 
"Range" );
   300       return QObject::tr( 
"Minority" );
   302       return QObject::tr( 
"Majority" );
   304       return QObject::tr( 
"Variety" );
   306       return QObject::tr( 
"Q1" );
   308       return QObject::tr( 
"Q3" );
   310       return QObject::tr( 
"IQR" );
 void reset()
Resets the calculated values. 
 
Statistic
Enumeration of flags that specify statistics to be calculated. 
 
Variety (count of distinct) values. 
 
void finalize()
Must be called after adding all values with addValues() and before retrieving any calculated statisti...
 
void addVariant(const QVariant &value)
Adds a single value to the statistics calculation. 
 
Sample standard deviation of values. 
 
Number of missing (null) values. 
 
Inter quartile range (IQR) 
 
QgsStatisticalSummary(QgsStatisticalSummary::Statistics stats=QgsStatisticalSummary::All)
Constructor for QgsStatisticalSummary. 
 
double statistic(QgsStatisticalSummary::Statistic stat) const
Returns the value of a specified statistic. 
 
static QString displayName(QgsStatisticalSummary::Statistic statistic)
Returns the friendly display name for a statistic. 
 
void calculate(const QList< double > &values)
Calculates summary statistics for a list of values. 
 
Standard deviation of values. 
 
Range of values (max - min) 
 
void addValue(double value)
Adds a single value to the statistics calculation.