This calculates the sum of Poisson distribution,
Sum(n=0..N0)P(mu,n)
= exp(-mu)[1 + mu/1 [1 + mu/2 [1 + mu/3[ .... [1 + mu/N0]....]]]]
mu : expected value
N0 : upper limit of n (0 or positive integer)
The contents of x, y, z and t stack registers are destroyed.
No flags are used.
R00 : current n
XEQ "SigmaPSN" enter mu and N0 R/S ... shows the sum
V1.00 February 12, 2007
00 { 60-Byte Prgm } ; 01 LBL "SigmaPSN" ; Sigma=ALPHA down MATH Sigma 02 MVAR "mu" ; mu = ALPHA down MATH mu 03 MVAR "N0" ; 04 VARMENU "SigmaPSN" ; 05 STOP ; 06 EXITALL ; 07 1 ; 08 STO 00 ; avoid divide by 0 if N0==0 09 RCL "N0" ; 10 X=0? ; 11 GTO 02 ; if N0==0, 0 is kept in x 12 STO 00 ; else R00=N0 13 1 ; x = 1 14 LBL 02 ; 15 RCLx "mu" ; multiply the current x 16 RCL/ 00 ; 17 1 ; 18 + ; 19 DSE 00 ; 20 GTO 02 ; 21 RCL "mu" ; multiply e^-mu 22 +/- ; 23 E^X ; 24 x ; 25 .END. ;
Programmed by Taku Yamanaka, February 12, 2007.