Class TableOneWay
- All Implemented Interfaces:
Serializable,Cloneable
TableOneWay calculates a frequency table for a data array.
A one-way frequency table can be used to visualize the shape of the
data distribution and look for anomalies in the data. There are many
approaches to constructing frequency tables. Four approaches are
implemented in this class:
- equal width class intervals based upon the smallest and largest observations,
- equal width class intervals based upon a user provided minimum and maximum,
- class intervals defined from user provided class midpoints, and
- class intervals defined from user provided class boundaries.
The TableOneWay class implements the first two approaches by
overloading the getFrequencyTable method. If
getFrequencyTable() is used without input arguments,
nIntervals of equal length are formed between the minimum and maximum values
in the data. The frequency table returned from this method contains tallies
of the number of observations in each interval. The data minimum and
maximum can be obtained using getMinimum and getMaximum.
Instead of using the minimum and maximum to define the boundaries of the
smallest and largest classes, specified boundaries can be used by calling
getFrequencyTable(lower_bound, upper_bound). This method
tallies all data less than or equal to the lower_bound into
the first class, and all data greater than or equal to upper_bound
into the last class.
The third approach is implemented using the
getFrequencyTableUsingClassmarks method. Equally spaced intervals
can be defined using class marks. In this approach a double precision array
of length nIntervals containing the class midpoints is passed to the
getFrequencyTableUsingClassmarks(classmarks[]). The class marks,
or midpoints, must be equally spaced.
Finally in those applications where unequal length intervals are preferred,
the getFrequencyTableUsingCutpoints(cutpoints[]) method can be used.
The double precision array cutpoints has length
nIntervals-1 and contains the class boundaries listed in ascending
order. The first cut point defines the first class which is used to tally
all data less than or equal to the first cut point value. The last cut point
defines the last class which is used to tally all data greater than or
equal to the last cut point value.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble[]Returns the one-way frequency table.double[]getFrequencyTable(double lower_bound, double upper_bound) Returns a one-way frequency table using known bounds.double[]getFrequencyTableUsingClassmarks(double[] classmarks) Returns the one-way frequency table using class marks.double[]getFrequencyTableUsingCutpoints(double[] cutpoints) Returns the one-way frequency table using cutpoints.doubleReturns maximum value ofx.doubleReturns the minimum value ofx.
-
Constructor Details
-
TableOneWay
public TableOneWay(double[] x, int nIntervals) Constructor forTableOneWay.- Parameters:
x- Adoublearray containing the observations.nIntervals- Anintscalar containing the number of intervals (bins).
-
-
Method Details
-
getMinimum
public double getMinimum()Returns the minimum value ofx.- Returns:
- a
doublecontaining the minimum data bound.
-
getMaximum
public double getMaximum()Returns maximum value ofx.- Returns:
- a
doublecontaining the maximum data bound.
-
getFrequencyTable
public double[] getFrequencyTable()Returns the one-way frequency table.nIntervalsintervals of equal length are used with the initial interval starting with the minimum value inxand the last interval ending with the maximum value inx. The initial interval is closed on the left and the right. The remaining intervals are open on the left and the closed on the right. Each interval is of length(max-min)/nIntervals, wheremaxis the maximum value of x andminis the minimum value ofx.- Returns:
doublearray containing the one-way frequency table.
-
getFrequencyTableUsingCutpoints
public double[] getFrequencyTableUsingCutpoints(double[] cutpoints) Returns the one-way frequency table using cutpoints. The cutpoints are boundaries that must be provided in the arraycutpointsof lengthnIntervals-1. This option allows unequal interval lengths. The initial interval is closed on the right and includes the initial cutpoint as its right endpoint. The last interval is open on the left and includes all values greater than the last cutpoint. The remainingnIntervals-2 intervals are open on the left and closed on the right. ArgumentnIntervalsmust be greater than or equal to 3 for this option.- Parameters:
cutpoints-doublearray containing the cutpoints.- Returns:
doublearray containing the one-way frequency table.
-
getFrequencyTableUsingClassmarks
public double[] getFrequencyTableUsingClassmarks(double[] classmarks) Returns the one-way frequency table using class marks. Equally spaced class marks in ascending order must be provided in the arrayclassmarksof lengthnIntervals. The class marks are the midpoints of each of thenIntervals. Each interval is assumed to have lengthclassmarks[1] - classmarks[0].nIntervalsmust be greater than or equal to 2.- Parameters:
classmarks-doublearray containing either the cutpoints or the class marks.- Returns:
doublearray containing the one-way frequency table.
-
getFrequencyTable
public double[] getFrequencyTable(double lower_bound, double upper_bound) Returns a one-way frequency table using known bounds. The one-way frequency table is computed using two semi-infinite intervals as the initial and last intervals. The initial interval is closed on the right and includeslower_boundas its right endpoint. The last interval is open on the left and includes all values greater thanupper_bound. The remainingnIntervals - 2intervals are each of length(upper_bound - lower_bound)/ (nIntervals - 2)and are open on the left and closed on the right.nIntervalsmust be greater than or equal to 3.- Parameters:
lower_bound-doublespecifies the right endpoint.upper_bound-doublespecifies the left endpoint.- Returns:
doublearray containing the one-way frequency table.
-