07-03-2015, 03:59 PM
Given an integer input N > 2 the programme returns a chi^2 distributed deviate for degrees of freedom N.
Code:
::
CK1&Dispatch
BINT1
::
%2
2DUP
%>
NcaseSIZEERR
%/
BEGIN
%RAN
%PI
%*
%TAN
2DUPSWAP
%2
%*
%1-
%SQRT
%*
3PICK
%+
%1-
DUP
%0>
ITE
::
OVER
%SQ_
%1+
4PICK
%1-
3PICKOVER
%/
%LN
%*
5PICK
%2
%*
%1-
%SQRT
5ROLL
%*
%-
%EXP
%*
%RAN
%<
casedrpfls
SWAPDROPTRUE
;
2DROPFALSE
UNTIL
DUP
%+
;
;