ChiSquareTest (FPScript)

21.09.2021

Carries out a Chi-square goodness-of-fit test. The test checks whether the sample passed corresponds to the normal or exponential distribution specified.

Syntax

ChiSquareTest(Sample, ErrorProbability, NumberOfClasses, Assessment, Parameter1 [ , Parameter2 ])

 

The syntax of the ChiSquareTest function consists of the following parts:

Part

Description

Sample

The sample to be tested.

Permitted data structures are data series und signal. All numeric data types are permitted.

For complex data types the absolute value is formed.

If the argument is a list, then the function is executed for each element of the list and the result is also a list.

ErrorProbability

Specifies the error probability, on which the test is to be based, as a percentage.

Permitted data structures are scalar value. All numeric data types are permitted. The argument is transformed to the unit %.

The value must be greater or equal to 0 % and less or equal to 100 %.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

NumberOfClasses

Specifies the number of classes for the sample count.

Permitted data structures are scalar value. All integral data types are permitted.

The value must be greater or equal to 3.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Assessment

Specifies how many of the parameters specified in the following arguments were estimated from the sample. This affects the number of degrees of freedom on which the test is based. Can accept the values 0, 1, or 2.

Permitted data structures are scalar value. All integral data types are permitted.

The value must be greater or equal to 0 and less or equal to 2.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Parameter1

Specifies the mean of the normal distribution to be tested or the Lambda value of the exponential distribution to be tested.

Permitted data structures are scalar value. All numeric data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Parameter2

Only required for the normal distribution. It specifies its variance. If you omit it, a test is automatically performed for the exponential distribution.

Permitted data structures are scalar value. All numeric data types are permitted.

If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated.

Remarks

The result always has the data type 32-bit integer.

The Chi-square goodness-of-fit test performs a count for the sample, which is then compared with the expected distribution. The function sets the class limits in such a way that if the exact distribution to be tested is present, then the classes are all equally occupied. You must select the number of classes in such a way that at least 5 values are allotted to at least 20 % of the classes, and at least one value is allotted to all of the classes. If this is not the case, then no result can be determined.

The following values are possible as the result:

Value

Interpretation

0

The hypothesis was rejected, i.e. the sample does not originate from a population with the distribution specified.

1

The hypothesis was accepted, i.e. the sample originates from a population with the distribution specified.

2

No result could be determined (see above).

Available in

Option Enhanced Statistics

Examples

From a quantity of screws, only a random 20 were selected and their diameter was measured (in mm). The Chi-square goodness-of-fit test will be used to an error probability of 5% to determine whether the diameter of the measured screws originated from a normal distribution with an expected value of 0.75 and variance of 0.001. Three classes will be created for this.

Dim data = {0.79 mm, 0.68, 0.75, 0.73, 0.69, 0.77, 0.76, 0.74, 0.73, 0.68, 0.72, _
0.75, 0.71, 0.76, 0.69, 0.72, 0.70, 0.77, 071, 074}
ChiSquareTest(data, 5 %, 3, 0, 0.75 mm, 0.001 mm^2)
 

Results in 1s. The hypothesis cannot be rejected, i.e. the sample originates from a population with the normal distribution specified.

See Also

KolmogorovSmirnovTest Function

Goodness-of-Fit Test Analysis Object

Statistics Option

References

[1] "Hartung, Joachim": "Statistik (Statistics), 9th Edition", page 182 ff. "Oldenbourg Verlag GmbH, Munich",1993.ISBN 3-486-22055-1.

Share article or send as email:

You might be interested in these articles