Class QAccelPlot::Histogram¶
ClassList > QAccelPlot > Histogram
Samples counted into bins, convertible to BarSeries data.More...
#include <Histogram.hpp>
Public Properties¶
| Type | Name |
|---|---|
| property QML_ANONYMOUSint | binCount Read-only: number of bins; 0 for an invalid histogram. |
| property qreal | binWidth Read-only: the width of every bin, or NaN when the bins are not uniform. |
| property QList< qreal > | edges Read-only: the binCount + 1 bin edges in ascending order. |
| property qreal | total Read-only: sum of the bin counts, the number of samples inside the edges. |
| property bool | uniform Read-only: true when all bins have the same width. |
| property QList< qreal > | values Read-only: one value per bin, a count or, after density() , a density. |
Public Functions¶
| Type | Name |
|---|---|
| std::vector< double > | barData () const Returns binCount() interleaved (from, to, value) bars, one per bin, forBarSeries::setRangedData() . |
| Q_INVOKABLE QVariantList | bars () const Returns one object per bin with from ,to , andvalue , for the QMLBarSeries.setData() . |
| int | binCount () const Returns the number of bins; 0 for an invalid histogram. |
| double | binWidth () const Returns the width of every bin, or NaN when the bins are not uniform. |
| Q_INVOKABLE Histogram | density () const Returns a copy whose values are densities: count / ( total() × bin width). |
| const std::vector< double > & | edges () const Returns the binCount() + 1 bin edges in ascending order. |
| bool | isUniform () const Returns true when all bins have the same width. |
| double | total () const Returns the sum of the bin counts, the number of samples inside the edges. |
| const std::vector< double > & | values () const Returns one value per bin, a count or, after density() , a density. |
Public Static Functions¶
| Type | Name |
|---|---|
| std::vector< double > | decadeEdges (double min, double max) Returns the edges from min to__max at 1, 2, ..., 9 times each power of ten: the ticks of a logarithmic axis. |
| Histogram | fromCounts (std::vector< double > edges, std::vector< double > counts) Wraps data that is already binned: counts has one finite, non-negative value per bin between__edges . |
| Histogram | fromSamples (const double * samples, std::size_t sampleCount, int binCount) Counts sampleCount __samples into__binCount equal bins spanning the finite samples. |
| Histogram | fromSamples (const double * samples, std::size_t sampleCount, int binCount, double min, double max) Counts sampleCount __samples into__binCount equal bins from__min to__max . |
| Histogram | fromSamples (const double * samples, std::size_t sampleCount, std::vector< double > edges) Counts sampleCount __samples into the bins between__edges , which must be finite and strictly increasing. |
| Histogram | fromSamples (const float * samples, std::size_t sampleCount, int binCount) Float overload of fromSamples _(_samples _,_sampleCount _,_binCount ). |
| Histogram | fromSamples (const float * samples, std::size_t sampleCount, int binCount, double min, double max) Float overload of fromSamples _(_samples _,_sampleCount _,_binCount _,_min _,_max ). |
| Histogram | fromSamples (const float * samples, std::size_t sampleCount, std::vector< double > edges) Float overload of fromSamples _(_samples _,_sampleCount _,_edges ). |
| std::vector< double > | linearEdges (double min, double max, int binCount) Returns binCount + 1 equally spaced edges from__min to__max , or an empty vector for invalid arguments. |
| std::vector< double > | logEdges (double min, double max, int binCount) Returns binCount + 1 edges from__min to__max , equally spaced on a logarithmic axis. |
Detailed Description¶
A bin spans from its lower edge up to, but not including, its upper edge; the last bin also includes its upper edge. NaN samples and samples outside the edges are not counted.
The functions are stateless, so a histogram can be built on a worker thread and its data passed to postData().
const auto histogram = Histogram::fromSamples(samples.data(), samples.size(), 40);
bars->setRangedData(histogram.barData(), histogram.binCount());
In QML, histograms are created by the Histogram singleton, see HistogramFactory.
See also: HistogramFactory, BarSeries
Public Properties Documentation¶
property binCount¶
Read-only: number of bins; 0 for an invalid histogram.
property binWidth¶
Read-only: the width of every bin, or NaN when the bins are not uniform.
property edges¶
Read-only: the binCount + 1 bin edges in ascending order.
property total¶
Read-only: sum of the bin counts, the number of samples inside the edges.
property uniform¶
Read-only: true when all bins have the same width.
property values¶
Read-only: one value per bin, a count or, after density() , a density.
Public Functions Documentation¶
function barData¶
Returns binCount() interleaved (from, to, value) bars, one per bin, forBarSeries::setRangedData() .
function bars¶
Returns one object per bin with from ,to , andvalue , for the QMLBarSeries.setData() .
function binCount¶
Returns the number of bins; 0 for an invalid histogram.
function binWidth¶
Returns the width of every bin, or NaN when the bins are not uniform.
function density¶
Returns a copy whose values are densities: count / ( total() × bin width).
The bin areas sum to 1, so bins of different widths and data sets of different sizes are comparable. Returns the histogram unchanged when it already holds densities.
function edges¶
Returns the binCount() + 1 bin edges in ascending order.
function isUniform¶
Returns true when all bins have the same width.
function total¶
Returns the sum of the bin counts, the number of samples inside the edges.
function values¶
Returns one value per bin, a count or, after density() , a density.
Public Static Functions Documentation¶
function decadeEdges¶
Returns the edges from min to__max at 1, 2, ..., 9 times each power of ten: the ticks of a logarithmic axis.
min and max are the first and the last edge. min must be positive. Returns an empty vector for invalid arguments. The bins widen tenfold at each power of ten, so draw them as density().
function fromCounts¶
Wraps data that is already binned: counts has one finite, non-negative value per bin between__edges .
static Histogram QAccelPlot::Histogram::fromCounts (
std::vector< double > edges,
std::vector< double > counts
)
function fromSamples¶
Counts sampleCount __samples into__binCount equal bins spanning the finite samples.
static Histogram QAccelPlot::Histogram::fromSamples (
const double * samples,
std::size_t sampleCount,
int binCount
)
The range is 0 to 1 without finite samples, and widens by 0.5 on each side when all samples are equal.
function fromSamples¶
Counts sampleCount __samples into__binCount equal bins from__min to__max .
static Histogram QAccelPlot::Histogram::fromSamples (
const double * samples,
std::size_t sampleCount,
int binCount,
double min,
double max
)
function fromSamples¶
Counts sampleCount __samples into the bins between__edges , which must be finite and strictly increasing.
static Histogram QAccelPlot::Histogram::fromSamples (
const double * samples,
std::size_t sampleCount,
std::vector< double > edges
)
function fromSamples¶
Float overload of fromSamples _(_samples _,_sampleCount _,_binCount ).
static Histogram QAccelPlot::Histogram::fromSamples (
const float * samples,
std::size_t sampleCount,
int binCount
)
function fromSamples¶
Float overload of fromSamples _(_samples _,_sampleCount _,_binCount _,_min _,_max ).
static Histogram QAccelPlot::Histogram::fromSamples (
const float * samples,
std::size_t sampleCount,
int binCount,
double min,
double max
)
function fromSamples¶
Float overload of fromSamples _(_samples _,_sampleCount _,_edges ).
static Histogram QAccelPlot::Histogram::fromSamples (
const float * samples,
std::size_t sampleCount,
std::vector< double > edges
)
function linearEdges¶
Returns binCount + 1 equally spaced edges from__min to__max , or an empty vector for invalid arguments.
static std::vector< double > QAccelPlot::Histogram::linearEdges (
double min,
double max,
int binCount
)
function logEdges¶
Returns binCount + 1 edges from__min to__max , equally spaced on a logarithmic axis.
static std::vector< double > QAccelPlot::Histogram::logEdges (
double min,
double max,
int binCount
)
min must be positive. Returns an empty vector for invalid arguments.
The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/data/Histogram.hpp