Post Reply 
(49G) chi^2 deviate programme
07-03-2015, 03:59 PM (This post was last modified: 06-15-2017 01:46 PM by Gene.)
Post: #1
(49G) chi^2 deviate programme
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
    %+
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)