Class Histogram allows the easy compilation of distribution statistics. To show how to use this class, here is a brief example which employs the uniform random number generator as a source of random deviates:
#include <rw/histo.h> #include <rw/rand.h> #include <iostream.h>
main() { RWTRandUniform<RWRandGenerator> ru; // Vector of 100 random points: RWMathVec<double> v(100,ru);
/* * Construct a histogram with 10 bins, * encompassing the data in v. * This will also initialize the histogram * with the data in v. */ Histogram hg(10, v);
// Print the results: cout << hg << "\n"; }
Note that the counts in class Histogram are in a public RWMathVec<int> base class; it can be used anywhere an integer vector can be used:
Histogram hg1; Histogram hg2;
. . // Fill up hg1 and hg2. .
// Calculate and print the sum of the two histograms:
cout << hg1 + hg2;>
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.