[comp.sys.handhelds] Probability routines

akcs.briank@hpcvbbs.UUCP (Brian Korver) (06/29/91)

Below ois an HP48SX directory full of probability routines.  However,
I'm only half way through the course right now so I'll add the rest
as I go along.  Although most of these routines are pretty simple,
downloading them is much easier than typing them all in yourself.

However, I'm not sure about the Poisson distrubtion function for Lamda
(is this how you spell it???) large.  In my text it describes a 
computer program that will calculate this dist. function for any
value of Lamda.  However, using the formulae they suggest gives me
answers just like using the summation of the Poisson density function,
instead of the answers they give in their example of the program
running.  So if you figure out how it is supposed to work (supposing
my dist. funciton is incorrect), let me know.

---- Here is the directory --0-
%%HP: T(3)A(D)F(.);
DIR
  COMBNATION
    \<< \-> X Y 'COMB(X
,Y)'
    \>>
  BANG
    \<< !
    \>>
  Bin
    \<<
"Binomial Density
Function.
Enter n p i"
{ ALG V } INPUT
OBJ\-> \-> n p I
      \<< 'COMB(n,I)*
p^I*(1-p)^(n-I)'
EVAL "p{X=" RCLF
STD SWAP I 4 RND +
SWAP STOF "}=" +
SWAP 4 RND +
      \>>
    \>>
  Bin.D
    \<<
"Binomial Distribution
Function.  
Enter n p i"
{ ALG V } INPUT
OBJ\-> \-> n p I
      \<< '\GS(x=0,I,
COMB(n,x)*p^x*(1-p)
^(n-x))' EVAL
"p{X\<=" RCLF STD
SWAP I 4 RND + SWAP
STOF "}=" + SWAP 4
RND +
      \>>
    \>>
  Pois
    \<<
"Poisson Density
Function.
Enter \Gl (or 'n*p') i"
{ ALG V } INPUT
OBJ\-> \-> L I
      \<< 'EXP(-L)*L^
I/I!' EVAL "p{X="
RCLF STD SWAP I 4
RND + SWAP STOF
"}=" + SWAP 4 RND +
      \>>
    \>>
  Pois.D
    \<<
"Poisson Distribution
Function. (ok \Gl<200?) 
Enter \Gl (or 'n*p') i"
{ ALG V } INPUT
OBJ\-> \-> L I
      \<< '\GS(x=0,I,
EXP(-L)*L^x/x!)'
EVAL "p{X\<=" RCLF
STD SWAP I 4 RND +
SWAP STOF "}=" +
SWAP 4 RND +
      \>>
    \>>
  Normal
    \<<
"Normal Distribution
Unit Transformation.
Enter \Gm \Gs x"
{ ALG V } INPUT
OBJ\-> \-> m s x
      \<< "'\O/(" '(x-m
)/s' EVAL DUP 3
ROLLD 3 RND + ")="
+ SWAP 2 RND 0 1
ROT UTPN NEG 1 + +
"'" + OBJ\->
      \>>
    \>>
  DeMoivre.Laplace
    \<<
"DeMoivre-Laplace
Distribution.
Enter n p a b"
{ ALG V } INPUT
OBJ\-> \-> n p a b
      \<< 'n*p' EVAL
'\v/(n*p*(1-p))' EVAL
\-> m s
        \<< "'\O/(" '(b
+.5-m)/s' EVAL \->NUM
3 RND + ")-\O/(" + '(
a-.5-m)/s' EVAL
\->NUM 3 RND + ")=" +
0 1 '(b+.5-m)/s'
\->NUM 2 RND UTPN NEG
1 + 0 1 '(a-.5-m)/s
' \->NUM 2 RND UTPN
NEG 1 + - + "'" +
OBJ\->
        \>>
      \>>
    \>>
  Expo
    \<<
"Exponential Distribution
Function.
Enter \Gl i"
{ ALG V } INPUT
OBJ\-> \-> L I
      \<< '1-EXP(-L*I
)' EVAL "p{X<" RCLF
STD SWAP I 4 RND +
SWAP STOF "}=" +
SWAP 4 RND +
      \>>
    \>>
END
----------------