Binomial Probability Distribution
|
05-27-2015, 12:51 PM
(This post was last modified: 05-27-2015 01:13 PM by Dieter.)
Post: #8
|
|||
|
|||
RE: Binomial Probability Distribution
(05-26-2015 03:47 PM)Dave Britten Wrote: First post updated with a new listing. Thanks for the algebra optimization tips. Great. Here's my solution. It has 74 steps including its own COMB routine. If you want to use your own external function, simply replace steps 16...32 with your COMB command. The program then is down to 58 steps. The code below implements another feature that I consider very useful especially for large n resp. wide ranges between k1 and k2. Take for instance this example: n=100, p=0,1, k=10...90 The result is 0,5487 and requires the summation of 80 single PDFs. The previous version of my program required 43,5 seconds for this. However, there is not much sense in adding the PDFs for k=50, 60 or even 90. They are so small that they do not change the final result. At k=40 the PDF already has dropped to 2,47 E–15, so the addition loop can stop here, or even earlier. This is checked by the program version below: if an additional PDF does not change the CDF sum, the program exits. In the example above the last added term is the PDF for k=36, which was 1,16 E–11 so that it did not change the final result of 0,5487. Which of course is returned much faster now: instead of 43,5 s only 18,5 s are required – less than half the time. Finally, here is the code: Code: 01 LBL"BINCDF" Now try your example: Code: 120 [ENTER] 6 [1/x] 40 [ENTER] 120 The result now is returned in 25 seconds. That's more than twice as fast as the standard approach since only PDFs between k=41 and k=59 had to be summed up. That's merely 19 loops instead of 80(!): Code: LastX => 1,7254 E–16 (last summed = first negligible PDF(k)) Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Binomial Probability Distribution - Dave Britten - 05-24-2015, 05:58 PM
RE: Binomial Probability Distribution - Dieter - 05-25-2015, 09:51 PM
RE: Binomial Probability Distribution - Dave Britten - 05-25-2015, 10:11 PM
RE: Binomial Probability Distribution - Dieter - 05-25-2015, 10:38 PM
RE: Binomial Probability Distribution - Dave Britten - 05-25-2015, 10:51 PM
RE: Binomial Probability Distribution - Dave Britten - 05-26-2015, 03:47 PM
RE: Binomial Probability Distribution - Dieter - 05-27-2015 12:51 PM
RE: Binomial Probability Distribution - Dieter - 05-26-2015, 10:38 PM
RE: Binomial Probability Distribution - Dave Britten - 05-28-2015, 01:44 AM
RE: Binomial Probability Distribution - Dieter - 05-28-2015, 11:11 AM
|
User(s) browsing this thread: 3 Guest(s)