Package de.erichseifert.gral.data.statistics


package de.erichseifert.gral.data.statistics

Summary statistics and frequency distributions of data values.

Statistics computes measures over any Iterable of comparable values — a whole data source, a single Column, or one Record. Measures are named by string constants on the class and computed on first request, then cached:

Statistics stats = data.getStatistics();
double mean = stats.get(Statistics.MEAN);
double iqr  = stats.get(Statistics.QUARTILE_3) - stats.get(Statistics.QUARTILE_1);

// Per column rather than over the whole table:
DataSource means = data.getColumnStatistics(Statistics.MEAN);

Non-numeric and null values are skipped, so the element count Statistics.N counts only the values that contributed.

Histogram counts how many values fall into each of a series of bins, either at breaks you supply or at equidistant breaks derived from the data:

Iterable<Comparable<?>> values =
    Arrays.<Comparable<?>>asList(1.0, 2.0, 2.5, 7.0);
Histogram histogram = new Histogram(values, 10);
for (Integer count : histogram) {
    // …one count per bin, in order
}

Histogram2D is the older, data-source-shaped variant: it is itself a DataSource, so it can be handed straight to a plot.