CNL Stat : Tests of Goodness of Fit : chi_squared_normality_test
chi_squared_normality_test
Performs a chi-squared test for normality.
Synopsis
#include <imsls.h>
float imsls_f_chi_squared_normality_test (int n_categories, int n_observations, float x[], ..., 0)
The type double function is imsls_d_chi_squared_normality_test.
Required Arguments
int n_categories (Input)
Number of cells into which the observations are to be tallied. n_categories must be at least 2.
int n_observations (Input)
Number of observations.
float x[] (Input)
Array of size n_observations containing the observations.
Return Value
The p-value for the chi-squared test for normality. An approximate probability is computed.
Synopsis with Optional Arguments
#include <imsls.h>
float imsls_f_chi_squared_normality_test (int n_categories, int n_observations, float x[],
IMSLS_CHI_SQUARED, float *chi_squared,
IMSLS_DEGREES_OF_FREEDOM, float *df,
0)
Optional Arguments
IMSLS_CHI_SQUARED, float *chi_squared (Output)
If specified, the chi-squared test statistic is returned in *chi_squared.
IMSLS_DEGREES_OF_FREEDOM, float *df (Output)
If specified, the degrees of freedom for the chi-squared goodness-of-fit test is returned in *df.
Description
This function computes the chi-squared statistic, its p-value, and the degrees of freedom of the test. Argument n_categories finds the number of intervals into which the observations are to be divided. The intervals are equiprobable except for the first and last interval, which are infinite in length.
If more flexibility is desired for the specification of intervals, the same test can be performed with a call to function imsls_f_chi_squared_test using the optional arguments described for that function.
Example
This example is taken from Conover (1980, pp. 195, 364). The data consists of 50 two-digit numbers taken from a telephone book. Since p_value is greater than 0.1 the chi-squared test fails to reject the null hypothesis of normality.
 
#include <imsls.h>
#include <stdio.h>
int main()
{
int n_observations = 50;
int n_categories = 6;
float x[] = {23.0, 36.0, 54.0, 61.0, 73.0, 23.0,
37.0, 54.0, 61.0, 73.0, 24.0, 40.0,
56.0, 62.0, 74.0, 27.0, 42.0, 57.0,
63.0, 75.0, 29.0, 43.0, 57.0, 64.0,
77.0, 31.0, 43.0, 58.0, 65.0, 81.0,
32.0, 44.0, 58.0, 66.0, 87.0, 33.0,
45.0, 58.0, 68.0, 89.0, 33.0, 48.0,
58.0, 68.0, 93.0, 35.0, 48.0, 59.0,
70.0, 97.0};
float p_value, df, chi_squared;
 
p_value = imsls_f_chi_squared_normality_test( n_categories,
n_observations, x,
IMSLS_DEGREES_OF_FREEDOM, &df,
IMSLS_CHI_SQUARED, &chi_squared,
0);
 
printf ("p-value = %11.4f\n", p_value);
printf ("degrees of freedom = %11.4f\n", df);
printf ("chi squared test = %11.4f\n", chi_squared);
}
Output
 
p-value = 0.4208
degrees of freedom = 5.0000
chi squared test = 4.9600