HP Forums

Full Version: (49G) chi^2 deviate programme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
    %+
  ;
;
Reference URL's