Investment Studio > Expressions > Functions > Statistical > CHI2
float chi2(float array[rows][cols] actual_values, float array[rows][cols] expected_values)
Returns the c2 (chi-squared) statistic (used in the standard c2 test; see chitest) computed from values in actual_values and expected_values.
The two arrays actual_values and expected_values must have the same dimensions. All array elements are converted to float. If conversion fails, the default value 0.0 is used.
The c2 statistic is a measure of the deviation of actual values from expected values. Given N actual and N expected values,
| N | ||
| c2 = | å | (actual[k] - expected[k])2 |
| ¾¾¾¾¾¾¾¾¾¾¾ | ||
| expected[k] | ||
| k = 1 |
Example
The c2 statistic of measured values {1, 2, 3} and expected values {3, 2, 1} is
=chi2({1, 2, 3}, {3, 2, 1})
= 5.333...