24 void QgsHistogram::prepareValues()
26 std::sort( mValues.begin(), mValues.end() );
30 s.calculate( mValues );
33 mIQR = s.interQuartileRange();
60 return 2.0 * mIQR * std::pow( mValues.count(), -1 / 3.0 );
70 double binWidth = ( mMax - mMin ) / bins;
73 edges.reserve( bins + 1 );
75 double current = mMin;
76 for (
int i = 0; i < bins; ++i )
86 QList<double> edges =
binEdges( bins );
89 binCounts.reserve( bins );
90 int currentValueIndex = 0;
91 for (
int i = 0; i < bins; ++i )
94 while ( currentValueIndex < mValues.count() && mValues.at( currentValueIndex ) < edges.at( i + 1 ) )
98 if ( currentValueIndex >= mValues.count() )
104 if ( currentValueIndex < mValues.count() )
107 binCounts[ bins - 1 ] = binCounts.last() + 1;
QList< double > binEdges(int bins) const
Returns a list of edges for the histogram for a specified number of bins.
static QList< double > getDoubleValues(const QgsVectorLayer *layer, const QString &fieldOrExpression, bool &ok, bool selectedOnly=false, int *nullCount=nullptr, QgsFeedback *feedback=nullptr)
Fetches all double values from a specified field name or expression.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Inter quartile range (IQR)
void setValues(const QList< double > &values)
Assigns numeric source values for the histogram.
QList< int > counts(int bins) const
Returns the calculated list of the counts for the histogram bins.
void setStatistics(QgsStatisticalSummary::Statistics stats)
Sets flags which specify which statistics will be calculated.
Calculator for summary statistics for a list of doubles.
Represents a vector layer which manages a vector based data sets.
int optimalNumberBins() const
Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule...
double optimalBinWidth() const
Calculates the optimal bin width using the Freedman-Diaconis rule.