Click or drag to resize
ChiSquaredTest Class
Chi-squared goodness-of-fit test.
Inheritance Hierarchy
SystemObject
  Imsl.StatChiSquaredTest

Namespace: Imsl.Stat
Assembly: ImslCS (in ImslCS.dll) Version: 6.5.2.0
Syntax
[SerializableAttribute]
public class ChiSquaredTest

The ChiSquaredTest type exposes the following members.

Constructors
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetCellCounts
Returns the cell counts.
Public methodGetCutpoints
Returns the cutpoints.
Public methodGetExpectedCounts
Returns the expected counts.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSetCutpoints
Sets the cutpoints.
Public methodSetRange
Sets endpoints of the range of the distribution.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUpdate(Double, Double)
Adds a new observation to the test.
Public methodUpdate(Double, Double)
Adds new observations to the test.
Top
Properties
  NameDescription
Public propertyChiSquared
The chi-squared statistic.
Public propertyDegreesOfFreedom
Returns the degrees of freedom in chi-squared.
Public propertyP
The p-value for the chi-squared statistic.
Top
Remarks

ChiSquaredTest performs a chi-squared goodness-of-fit test that a random sample of observations is distributed according to a specified theoretical cumulative distribution. The theoretical distribution, which may be continuous, discrete, or a mixture of discrete and continuous distributions, is specified via a user-defined function F where F implements ICdfFunction. Because the user is allowed to specify a range for the observations in the SetRange method, a test that is conditional upon the specified range is performed.

ChiSquaredTest can be constructed in two different ways. The intervals can be specified via the array cutpoints. Otherwise, the number of cutpoints can be given and equiprobable intervals computed by the constructor. The observations are divided into these intervals. Regardless of the method used to obtain them, the intervals are such that the lower endpoint is not included in the interval while the upper endpoint is always included. The user should determine the cutpoints when the cumulative distribution function has discrete elements since ChiSquaredTest cannot determine them in this case.

By default, the lower and upper endpoints of the first and last intervals are -\infty and +\infty, respectively. The method SetRange can be used to change the range.

A tally of counts is maintained for the observations in x as follows:

If the cutpoints are specified by the user, the tally is made in the interval to which x_i belongs, using the user-specified endpoints.

If the cutpoints are determined by the class then the cumulative probability at x_i, F(x_i), is computed using Cdf.

The tally for x_i is made in interval number \lfloor mF(x) + 1 \rfloor, where m is the number of categories and \lfloor.\rfloor is the function that takes the greatest integer that is no larger than the argument of the function. If the cutpoints are specified by the user, the tally is made in the interval to which x_i belongs using the endpoints specified by the user. Thus, if the computer time required to calculate the cumulative distribution function is large, user-specified cutpoints may be preferred in order to reduce the total computing time.

If the expected count in any cell is less than 1, then a rule of thumb is that the chi-squared approximation may be suspect. A warning message to this effect is issued in this case, as well as when an expected value is less than 5.

See Also

Reference

Other Resources