User's Guide to the GNU C++ Class Library - Data
Node: Data
Next: Curses
Prev: Random
Up: Top
Data Collection
Libg++ currently provides two classes for data collection and analysis of the collected data.
SampleStatistic
Class SampleStatistic
provides a means of accumulating samples of double
values and providing common sample statistics.
Assume declaration of double x
.
-
SampleStatistic a;
-
declares and initializes a.
-
a.reset();
-
re-initializes a.
-
a += x;
-
adds sample x.
-
int n = a.samples();
-
returns the number of samples.
-
x = a.mean;
-
returns the means of the samples.
-
x = a.var()
-
returns the sample variance of the samples.
-
x = a.stdDev()
-
returns the sample standard deviation of the samples.
-
x = a.min()
-
returns the minimum encountered sample.
-
x = a.max()
-
returns the maximum encountered sample.
-
x = a.confidence(int p)
-
returns the p-percent (0 <= p < 100) confidence interval.
-
x = a.confidence(double p)
-
returns the p-probability (0 <= p < 1) confidence interval.
SampleHistogram
Class SampleHistogram
is a derived class of SampleStatistic
that supports collection and display of samples in bucketed intervals. It supports the following in addition to SampleStatisic
operations.
-
SampleHistogram h(double lo, double hi, double width);
-
declares and initializes h to have buckets of size width from lo to hi. If the optional argument width is not specified, 10 buckets are created. The first bucket and also holds samples less than lo, and the last one holds samples greater than hi.
-
int n = h.similarSamples(x)
-
returns the number of samples in the same bucket as x.
-
int n = h.inBucket(int i)
-
returns the number of samples in bucket i.
-
int b = h.buckets()
-
returns the number of buckets.
-
h.printBuckets(ostream s)
-
prints bucket counts on ostream s.
-
double bound = h.bucketThreshold(int i)
-
returns the upper bound of bucket i.
Next: Curses
Up: Top