JMSLTM Numerical Library 5.0.1

com.imsl.stat
Class TableOneWay

java.lang.Object
  extended by com.imsl.stat.TableOneWay
All Implemented Interfaces:
Serializable, Cloneable

public class TableOneWay
extends Object
implements Serializable, Cloneable

Class 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:

  1. equal width class intervals based upon the smallest and largest observations,
  2. equal width class intervals based upon a user provided minimum and maximum,
  3. class intervals defined from user provided class midpoints, and
  4. 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:
Example, Serialized Form

Constructor Summary
TableOneWay(double[] x, int nIntervals)
          Constructor for TableOneWay.
 
Method Summary
 double[] getFrequencyTable()
          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.
 double getMaximum()
          Returns maximum value of x.
 double getMinimum()
          Returns the minimum value of x.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableOneWay

public TableOneWay(double[] x,
                   int nIntervals)
Constructor for TableOneWay.

Parameters:
x - A double array containing the observations.
nIntervals - An int scalar containing the number of intervals (bins).
Method Detail

getFrequencyTable

public double[] getFrequencyTable()
Returns the one-way frequency table. nIntervals intervals of equal length are used with the initial interval starting with the minimum value in x and the last interval ending with the maximum value in x. 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, where max is the maximum value of x and min is the minimum value of x.

Returns:
double array 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 includes lower_bound as its right endpoint. The last interval is open on the left and includes all values greater than upper_bound. The remaining nIntervals - 2 intervals are each of length (upper_bound - lower_bound)/ (nIntervals - 2) and are open on the left and closed on the right. nIntervals must be greater than or equal to 3.

Parameters:
lower_bound - double specifies the right endpoint.
upper_bound - double specifies the left endpoint.
Returns:
double array 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 array classmarks of length nIntervals. The class marks are the midpoints of each of the nIntervals. Each interval is assumed to have length classmarks[1] - classmarks[0]. nIntervals must be greater than or equal to 2.

Parameters:
classmarks - double array containing either the cutpoints or the class marks.
Returns:
double array 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 array cutpoints of length nIntervals-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 remaining nIntervals-2 intervals are open on the left and closed on the right. Argument nIntervals must be greater than or equal to 3 for this option.

Parameters:
cutpoints - double array containing the cutpoints.
Returns:
double array containing the one-way frequency table.

getMaximum

public double getMaximum()
Returns maximum value of x.

Returns:
a double containing the maximum data bound.

getMinimum

public double getMinimum()
Returns the minimum value of x.

Returns:
a double containing the minimum data bound.

JMSLTM Numerical Library 5.0.1

Copyright © 1970-2008 Visual Numerics, Inc.
Built July 8 2008.