Chapter 4 Collecting Statistics
Learning Objectives
- To be able to collect statistics using classes within the JSL
To understand the basics of statistical computations supported by the JSL
The JSL has a wide variety of classes that support statistic computations. A main theme in understanding the usage of the classes within the jsl.utilities.statistics
package is the concept of collection. This concept is encapsulated within the interface, CollectorIfc
interface. The methods of the CollectorIfc
interface are illustrated in Figure 4.1.
Something is a collector, if it implements the CollectorIfc
interface. The implication is that those values presented to the various collect
methods will be observed and tabulated into various quantities based on the presented values. The collect
method has been overridden to facilitate collection of double values, arrays of double values, and boolean values. The two parameter collect
methods permit collection of a second set of values. The second parameter is meant to represent the weight associated with the first parameter. As we will see, this facilitates the collection of weighted statistics. Collection can be turned on or off and can be reset. Turning collection off should cause the presented values to be ignored during the off period. Resetting a collector should set the state of the collector as if no values had been presented. Thus, resetting a collector should clear all previous collection results.
Figure 4.2 presents the major classes and interfaces within the statistics package. The CollectIfc
interface is implemented within the abstract base class AbstractCollector
, which serves as the basis for various concrete implementations of statistical collectors. The SaveDataIfc
interface defines methods for indicating whether or not the data collected should be saved into arrays. There are two major kinds of statistics one of which assumes that the values presented must be weighted, the WeightedStatisticIfc
interface and the WeightedStatistic
class. While the other branch of classes, derived from AbstractStatistic
do not necessarily have to be weighted. The main classes to be discussed here are Statistic
and Histogram
.