Post Reply 
(35S) Statistical Distributions Functions
11-20-2015, 01:19 PM (This post was last modified: 11-20-2015 02:30 PM by Dieter.)
Post: #67
RE: HP 35s Statistical Distributions Functions
(11-20-2015 12:09 PM)PedroLeiva Wrote:  Excellent idea. The inclusion of discrete variables complement the main statistical functions.

Here is a short and not at all optimized listing for the Poisson and Binomial cdfs. Simply add it to the current code. It's less than 50 steps.

Code:
P001 LBL P    // Poisson CDF
P002 XEQ J012 // initialize (O=1, T=2 etc.)
P003 INPUT L  // prompt for parameter lambda
P004 x<=0?
P005 GTO P003 // accept only positive lambda
P006 INPUT X
P007 x<0?
P008 GTO P006 // reject negative x
P009 RCL+ O
P010 STO A
P011 RCL L
P012 STO Y
P013 XEQ G006  // Call regularized Gamma. Check: this points to RCL A RCL+T...
P014 x<>y      // rearrange output so that P(x,lambda) is in X
P015 STOP
P016 GTO P006

O001 LBL 0     // Binomial CDF - LBL B is already in use ;-)
O002 -14       // prompt for n and initialize
O003 XEQ J001
O004 INPUT P
O005 RCL O
O006 RCL P
O007 x<y?
O008 x<=0?
O009 GTO O004  // reject if p<=0 or p>=1
O010 XEQ A001
O011 x<0?
O012 GTO O010  // reject negative x
O013 RCL N
O014 RCL X
O015 x<y?
O016 GTO O020
O017 CLSTK     // if x>=n
O018 RCL O     // return cdf = 1
O019 GTO O029
O020 RCL+ O
O021 STO A
O022 RCL N
O023 RCL- X
O024 STO B
O025 RCL P
O026 STO Y
O027 XEQ I016   // Call regularized Beta. Check: this points to RCL A  RCL B  XEQ B010
O028 x<>y       // rearrange output as acutally 1-cdf was calculated
O029 STOP
O030 GTO O010

If this does not work you may have an older version of the other distributions. Especially if in some cases the correct Poisson result apprears in Y instead of X. ;-)

Test examples:
Poisson cdf for lambda=7,3 and x=5 is 0,26404.
Binomial cdf for n=20, p=0,2 and x=6 is 0,91331.

(11-20-2015 12:09 PM)PedroLeiva Wrote:  In that sense I attach the programs I wrote for the HP 35s, including the listing of programming instructions and numerical examples. I ask pardon because the instructions are written in my native tongue, Spanish.
I learned to compress files, lets see if I did it well! Pedro

As far as I can tell these programs calculate the density functions (probability mass functions), but not the cumulative densities.

Two questions: First, why is it required to clear all variables (CLEAR 2), i.e. have the user lose all his data, before starting the programs? It's good practice that the program itselfs clears only the registers it requires. At the moment I even do not see a reason why any register has to be cleared at all. ?!?

And second: why does the Binomial distribution calculate the combinations nCx although there is a dedicated HP35s nCr function that does this faster and with less problems (e.g. overflow)? You have to know that this function exists since you used it for the Hypergeometric distribution. ;-)

BTW, it seems that the program titled "Distribución Polinomial" actually calculates the multinomial distribution (es: distribución multinomial). Since I am not sure about the correct Spanish term: is there a difference between these two expressions or do they refer to the same distribution? If yes: the multinomial distribution can be calculated much easier and without using so many registers.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 35s Statistical Distributions Functions - Dieter - 11-20-2015 01:19 PM



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