24 void QgsHistogram::prepareValues()
26 std::sort( mValues.begin(), mValues.end() );
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;
Base class for feedback objects to be used for cancellation of something running in a worker thread.
QList< int > counts(int bins) const
Returns the calculated list of the counts for the histogram bins.
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.
QList< double > binEdges(int bins) const
Returns a list of edges for the histogram for a specified number of bins.
void setValues(const QList< double > &values)
Assigns numeric source values for the histogram.
Calculator for summary statistics for a list of doubles.
void calculate(const QList< double > &values)
Calculates summary statistics for a list of values.
@ InterQuartileRange
Inter quartile range (IQR)
double interQuartileRange() const
Returns the inter quartile range of the values.
double min() const
Returns calculated minimum from values.
void setStatistics(QgsStatisticalSummary::Statistics stats)
Sets flags which specify which statistics will be calculated.
double max() const
Returns calculated maximum from values.
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.
Represents a vector layer which manages a vector based data sets.