Essays/Chi Squared CDF

From J Wiki
Jump to navigation Jump to search

The CDF of the distribution can be computed as follows.

gamma   =: ! & <:
ig0     =: 4 : '(1 H. (1+x) % x&((* ^) * (^ -)~)) y'
incgam  =: ig0 % gamma@[  NB. incomplete gamma
chisqcdf=: incgam&-:

The following examples compare calculated results against values from the Handbook of Mathematical Functions by Abramowitz and Stegun, Table 26.8.

   t26d8a=: 0.411740 0.554300 0.831211 1.145476  16.7496 20.515 22.105 25.745
   5 chisqcdf t26d8a
0.00499995 0.0100001 0.025 0.05 0.995 0.999 0.9995 0.9999

   t26d8b=: 15.137 18.421 21.108 23.513 25.745 27.856 29.877 31.828 33.720 35.564
   (1+i.10) chisqcdf t26d8b
0.9999 0.9999 0.9999 0.9999 0.9999 0.9999 0.9999 0.9999 0.9999 0.9999



See also


Contributed by Roger Hui. The verb definitions are from Ewart Shaw, Hypergeometric Functions and CDFs in J, Vector, Volume 18, Number 4, April 2002.