(35S) Statistical Distributions Functions
11-20-2015, 11:06 PM (This post was last modified: 11-21-2015 01:49 PM by Dieter.)
Post: #73
 Dieter Senior Member Posts: 2,398 Joined: Dec 2013
RE: HP 35s Statistical Distributions Functions
(11-20-2015 05:45 PM)PedroLeiva Wrote:  I loaded your labels for cumulative Binomial and Poisson function, they work perfectly well.

I have reworked this a bit so that now the same values as with the other distributions are returned. This includes the upper CDF (which in these cases is not just 1 minus the lower CDF) as well as the PDF (or PMF - probability mass function -, to be more precise).

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 RCL L     // calculate PDF/PMF P015 RCL X P016 y^x P017 RCL X P018 ! P019 ÷ P020 RCL L P021 +/- P022 e^x P023 x P024 STO C P025 +         // upper CDF = 1 - lower CDF + PMF P026 x<> C P027 STO D P028 x<>y P029 RCL C P030 x<>y P031 ENTER P032 CLx P033 STO A P034 STO B P035 R↓ P036 STOP P037 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 INPUT X O011 x<0? O012 GTO O010  // reject negative x O013 RCL N O014 RCL X O015 x<y? O016 GTO O023  // regular case: x < n O017 RCL N     // handle x=n separately O018 STO X O019 RCL O     // return cdf = 1 O020 ENTER O021 CLx       // and 1-cdf = 0 O022 GTO O032 O023 RCL+ O O024 STO A O025 RCL N O026 RCL- X O027 STO B O028 RCL P O029 STO Y O030 XEQ I016   // Call regularized Beta. Check: this points to RCL A  RCL B  XEQ B010 O031 STO C O032 R↓ O033 RCL N      // calculate PDF/PMF O034 RCL X O035 nCr O036 RCL P O037 RCL X O038 y^x O039 x O040 RCL O O041 RCL- P O042 RCL N O043 RCL- X O044 y^x O045 x O046 STO D O047 STO+ C    // upper CDF = 1 - lower CDF + PMF O048 x<>y O049 RCL C O050 x<>y O051 ENTER O052 CLx O053 STO A O054 STO B O055 R↓ O056 STOP O057 GTO O010

These versions return:

in Z: the Poisson resp. Binomial PDF, i.e. P(X=x)
in Y: the Poisson resp. Binomial upper CDF, i.e. P(X≥x)
in X: the Poisson resp. Binomial lower CDF, i.e. P(X≤x)

This matches the returned values for the Chi² and F distribution. Like in these cases, the upper CDF and the PDF are returned in registers C and D as well.

Looks like the user instructions need an update. ;-)

At the moment I don't think I'll add the Poisson and Binomial quantile functions – that's a rather complex story.

Edit: it looks like the Poisson quantile is not that complicated. At least an experimental version seems to run without major problems. ;-)

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread (35S) Statistical Distributions Functions - PedroLeiva - 10-25-2015, 12:19 AM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-25-2015, 01:29 PM RE: HP 35s Statistical Distributions Functions - SlideRule - 10-26-2015, 03:03 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-26-2015, 04:41 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-26-2015, 08:30 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-26-2015, 10:29 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-26-2015, 11:04 PM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-26-2015, 08:39 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-26-2015, 09:25 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-27-2015, 02:29 PM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-26-2015, 09:28 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-27-2015, 11:59 AM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-27-2015, 04:48 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-27-2015, 05:22 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-27-2015, 07:32 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-27-2015, 10:25 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-28-2015, 12:24 AM RE: HP 35s Statistical Distributions Functions - Dieter - 10-28-2015, 12:34 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-28-2015, 06:59 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-27-2015, 11:48 PM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-27-2015, 10:29 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-27-2015, 11:41 PM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-28-2015, 12:11 AM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-28-2015, 12:36 AM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-28-2015, 01:05 AM RE: HP 35s Statistical Distributions Functions - Dieter - 10-28-2015, 11:55 AM RE: HP 35s Statistical Distributions Functions - Thomas Klemm - 10-28-2015, 01:40 AM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-28-2015, 06:21 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-28-2015, 07:54 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-28-2015, 10:34 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-30-2015, 02:36 AM RE: HP 35s Statistical Distributions Functions - Dieter - 10-30-2015, 01:56 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-30-2015, 05:20 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-30-2015, 07:16 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-30-2015, 07:43 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-30-2015, 11:08 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-30-2015, 11:16 PM RE: HP 35s Statistical Distributions Functions - rprosperi - 10-31-2015, 09:11 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-28-2015, 10:45 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-29-2015, 12:09 AM RE: HP 35s Statistical Distributions Functions - Dieter - 10-29-2015, 07:01 AM RE: HP 35s Statistical Distributions Functions - Dieter - 10-29-2015, 07:18 AM RE: HP 35s Statistical Distributions Functions - Dieter - 10-29-2015, 11:56 PM RE: HP 35s Statistical Distributions Functions - Dieter - 10-31-2015, 09:05 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-01-2015, 12:44 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-01-2015, 09:17 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-05-2015, 01:37 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-05-2015, 02:16 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-13-2015, 06:59 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-13-2015, 08:04 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-13-2015, 09:05 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-14-2015, 11:22 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-15-2015, 03:04 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-15-2015, 09:26 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-16-2015, 01:13 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-16-2015, 07:08 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-16-2015, 10:47 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-17-2015, 12:44 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-17-2015, 09:20 PM RE: HP 35s Statistical Distributions Functions - Gerald H - 11-19-2015, 09:24 AM RE: HP 35s Statistical Distributions Functions - Dieter - 11-19-2015, 01:00 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-19-2015, 01:17 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-19-2015, 08:31 PM RE: HP 35s Statistical Distributions Functions - Gerald H - 11-19-2015, 05:52 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-20-2015, 12:09 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-20-2015, 01:19 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-20-2015, 05:45 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-20-2015, 08:30 PM RE: HP 35s Statistical Distributions Functions - Marcio - 11-20-2015, 08:37 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-20-2015, 08:54 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-20-2015 11:06 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-21-2015, 07:27 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-20-2015, 05:47 PM RE: HP 35s Statistical Distributions Functions - Marcio - 11-20-2015, 12:24 PM RE: HP 35s Statistical Distributions Functions - PedroLeiva - 11-26-2015, 11:07 PM RE: HP 35s Statistical Distributions Functions - Dieter - 11-27-2015, 06:41 AM RE: HP 35s Statistical Distributions Functions - Dieter - 11-29-2015, 06:50 PM

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