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> int 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: std::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: std::cout << hg1 + hg2; |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.