name: Histogram

synopsis:
g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_stat.a

#include <Histogram.h>

~Histogram();
Histogram();
Histogram(const Histogram& copy_sym);

boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);
boolean setMode(BIN_MODE mode);
boolean setDim(long dim);
boolean setBins(const TVector& bins);
boolean setBins(long num_bins = DEF_NUM_BINS, TIntegral min = DEF_MIN, TIntegral max = DEF_MAX);
boolean setCounts(const TVector& counts);
boolean compute(const Vector<TVector>& values);
boolean pdf(VectorDouble& pdf) const;
boolean cdf(MatrixDouble& pdf);
quick start:
#include <Histogram.h>

// test a 2-D histogram with a specified number of bins in EDGES mode
//
MatrixDouble expected_cdf.assign(3, 3, L"0.4, 0.4, 0.4, 0.4, 0.8, 0.8, 0.4, 0.8, 1"), actual_cdf;
Vector test_data(2);
test_data(0).assign(L"1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 4.1, 3.1, 2.1, 1.1");
test_data(1).assign(L"1.1, 2.1, 3.1, 4.1, 5.1, 7.1, 4.1, 3.1, 2.1, 1.1");

hist6.clear();
hist6.setScale(Histogram::LINEAR);
hist6.setMode(Histogram::EDGES);
hist6.setDim(2);
hist6.setBins(3, 1.0, 7.0);
hist6.compute(test_data);
hist6.cdf(actual_cdf);
if (!actual_cdf.almostEqual(expected_cdf)) {
  actual_cdf.debug(L"actual cdf");
  expected_cdf.debug(L"expected cdf");
  return Error::handle(name(), L"compute", Error::TEST, __FILE__,
    			 __LINE__);
}
description:

Histogram: a class for storing, computing, and updating multidimensional histograms of data. The Histogram class works under three binning scales In LINEAR and LOG scale binnings, the min, max values and the number of bins for each dimension can be specified.

The user can also specify how the bins are stored: using CENTERs or EDGES. This is more useful for the USER_DEFINED mode as the bins are manually set by the user only here: In both the modes, it is assumed that the centers or edges are in sorted order.

The base of the log in LOG scale binning is immaterial as all bases lead to same bins. If min and max are a and b, num bins is N, edge i in the log mode is given by: which is independent of the base. Here log base-10 is chosen.

The dimension of the histogram is defined using setDim method.

There are several ways of setting up the bins by using the various setBins methods:
  1. setBins(Vector& bins): In USER_DEFINED scale, specify bins for each dimension independently

  2. setBins(TVector& bins): In USER_DEFINED scale, the same set of bins in each dimension

  3. setBins(VectorLong& num_bins, TVector& min, TVector& max): In LINEAR and LOG scale, the bins are set using different bin parameters for each dimension

  4. setBins(long num_bins, TIntegral min, TIntegral max): In LINEAR or LOG scale, the same kind of bins in all dimensions

The getCount, pdf and cdf methods return a single array the multidimensional index of which can be obtained using the method: For computing one-dimensional histogram, use For getting the pdf and cdf in two-dimensional histograms, use:

dependencies:

public constants:

error codes:

protected data:

required public methods:

class-specific public methods:

private methods:

examples:

notes: