QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
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;
double optimalBinWidth() const
Calculates the optimal bin width using the Freedman-Diaconis rule.
Calculator for summary statistics for a list of doubles.
void setStatistics(QgsStatisticalSummary::Statistics stats)
Sets flags which specify which statistics will be calculated.
double min() const
Returns calculated minimum from values.
void setValues(const QList< double > &values)
Assigns numeric source values for the histogram.
@ InterQuartileRange
Inter quartile range (IQR)
double interQuartileRange() const
Returns the inter quartile range of the values.
double max() const
Returns calculated maximum from values.
int optimalNumberBins() const
Returns the optimal number of bins for the source values, calculated 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.
QList< int > counts(int bins) const
Returns the calculated list of the counts for the histogram bins.
void calculate(const QList< double > &values)
Calculates summary statistics for a list of 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.