28 : mStatistics( stats )
41 mFirst = std::numeric_limits<double>::quiet_NaN();
42 mLast = std::numeric_limits<double>::quiet_NaN();
48 mMin = std::numeric_limits<double>::max();
49 mMax = -std::numeric_limits<double>::max();
76 for (
const double value : values )
90 mMin = std::min( mMin, value );
91 mMax = std::max( mMax, value );
95 mValueCount.insert( value, mValueCount.value( value, 0 ) + 1 );
97 if ( mRequiresAllValueStorage )
103 bool convertOk =
false;
104 if ( !value.isValid() || value.isNull() )
108 const double val = value.toDouble( &convertOk );
120 mFirst = std::numeric_limits<double>::quiet_NaN();
121 mLast = std::numeric_limits<double>::quiet_NaN();
122 mMin = std::numeric_limits<double>::quiet_NaN();
123 mMax = std::numeric_limits<double>::quiet_NaN();
124 mMean = std::numeric_limits<double>::quiet_NaN();
125 mMedian = std::numeric_limits<double>::quiet_NaN();
126 mStdev = std::numeric_limits<double>::quiet_NaN();
127 mSampleStdev = std::numeric_limits<double>::quiet_NaN();
128 mMinority = std::numeric_limits<double>::quiet_NaN();
129 mMajority = std::numeric_limits<double>::quiet_NaN();
130 mFirstQuartile = std::numeric_limits<double>::quiet_NaN();
131 mThirdQuartile = std::numeric_limits<double>::quiet_NaN();
135 mMean = mSum / mCount;
139 double sumSquared = 0;
140 const auto constMValues = mValues;
141 for (
const double value : constMValues )
143 const double diff = value - mMean;
144 sumSquared += diff * diff;
146 mStdev = std::pow( sumSquared / mValues.count(), 0.5 );
147 mSampleStdev = std::pow( sumSquared / ( mValues.count() - 1 ), 0.5 );
155 std::sort( mValues.begin(), mValues.end() );
156 const bool even = ( mCount % 2 ) < 1;
159 mMedian = ( mValues[mCount / 2 - 1] + mValues[mCount / 2] ) / 2.0;
163 mMedian = mValues[( mCount + 1 ) / 2 - 1];
170 if ( ( mCount % 2 ) < 1 )
172 const int halfCount = mCount / 2;
173 const bool even = ( halfCount % 2 ) < 1;
176 mFirstQuartile = ( mValues[halfCount / 2 - 1] + mValues[halfCount / 2] ) / 2.0;
180 mFirstQuartile = mValues[( halfCount + 1 ) / 2 - 1];
185 const int halfCount = mCount / 2 + 1;
186 const bool even = ( halfCount % 2 ) < 1;
189 mFirstQuartile = ( mValues[halfCount / 2 - 1] + mValues[halfCount / 2] ) / 2.0;
193 mFirstQuartile = mValues[( halfCount + 1 ) / 2 - 1];
201 if ( ( mCount % 2 ) < 1 )
203 const int halfCount = mCount / 2;
204 const bool even = ( halfCount % 2 ) < 1;
207 mThirdQuartile = ( mValues[ halfCount + halfCount / 2 - 1] + mValues[ halfCount + halfCount / 2] ) / 2.0;
211 mThirdQuartile = mValues[( halfCount + 1 ) / 2 - 1 + halfCount ];
216 const int halfCount = mCount / 2 + 1;
217 const bool even = ( halfCount % 2 ) < 1;
220 mThirdQuartile = ( mValues[ halfCount + halfCount / 2 - 2 ] + mValues[ halfCount + halfCount / 2 - 1 ] ) / 2.0;
224 mThirdQuartile = mValues[( halfCount + 1 ) / 2 - 2 + halfCount ];
231 QList<int> valueCounts = mValueCount.values();
235 mMinority = mValueCount.key( *std::min_element( valueCounts.begin(), valueCounts.end() ) );
239 mMajority = mValueCount.key( *std::max_element( valueCounts.begin(), valueCounts.end() ) );
280 return mValueCount.count();
282 return mFirstQuartile;
284 return mThirdQuartile;
286 return mThirdQuartile - mFirstQuartile;
302 return QObject::tr(
"Count" );
304 return QObject::tr(
"Count (missing)" );
306 return QObject::tr(
"Sum" );
308 return QObject::tr(
"Mean" );
310 return QObject::tr(
"Median" );
312 return QObject::tr(
"St dev (pop)" );
314 return QObject::tr(
"St dev (sample)" );
316 return QObject::tr(
"Minimum" );
318 return QObject::tr(
"Maximum" );
320 return QObject::tr(
"Range" );
322 return QObject::tr(
"Minority" );
324 return QObject::tr(
"Majority" );
326 return QObject::tr(
"Variety" );
328 return QObject::tr(
"Q1" );
330 return QObject::tr(
"Q3" );
332 return QObject::tr(
"IQR" );
334 return QObject::tr(
"First" );
336 return QObject::tr(
"Last" );
348 return QStringLiteral(
"count" );
350 return QStringLiteral(
"countmissing" );
352 return QStringLiteral(
"sum" );
354 return QStringLiteral(
"mean" );
356 return QStringLiteral(
"median" );
358 return QStringLiteral(
"stdev" );
360 return QStringLiteral(
"stdevsample" );
362 return QStringLiteral(
"min" );
364 return QStringLiteral(
"max" );
366 return QStringLiteral(
"range" );
368 return QStringLiteral(
"minority" );
370 return QStringLiteral(
"majority" );
372 return QStringLiteral(
"variety" );
374 return QStringLiteral(
"q1" );
376 return QStringLiteral(
"q3" );
378 return QStringLiteral(
"iqr" );
380 return QStringLiteral(
"first" );
382 return QStringLiteral(
"last" );