ChiTest(ActualRange: Array; ExpectedRange: Array): Double;
ActualRange. Data range that contains the observations to be compared with the expected values.
ExpectedRange. Data range that contains the ratio of products of rows and columns totals to the general total.
The ChiTest method returns independence criterion: that is, probability of χ2 (ch-square) distribution for corresponding number of degrees of freedom.
The χ2 criterion is used to determine whether the hypothesis is confirmed by an experiment.
The ActualRange and ExpectedRange arrays must match in size. The ActualRange array must also contain only non-negative values, and the ExpectedRange array must contain only positive values.
To execute the example, add a link to the Stat system assembly.
Sub UserProc;
Var
st: Statistics;
d0: Double;
y, x: Array Of Double;
Begin
y := New Double[2, 3];
x := New Double[2, 3];
y[0, 0] := 58; y[1, 0] := 35;
y[0, 1] := 11; y[1, 1] := 25;
y[0, 2] := 10; y[1, 2] := 23;
x[0, 0] := 45.35; x[1, 0] := 47.65;
x[0, 1] := 17.56; x[1, 1] := 18.44;
x[0, 2] := 16.09; x[1, 2] := 16.91;
st := New Statistics.Create;
d0 := st.ChiTest(y, x);
If st.Status <> 0 Then
Debug.WriteLine(st.Errors);
Else
Debug.WriteLine("Value of independence criterion: " + d0.ToString);
End If;
End Sub UserProc;
After executing the example the console window displays the independence criterion value.
See also: