Post Reply 
(25) Binomial Probability Distribution
11-17-2019, 09:14 PM (This post was last modified: 11-17-2019 09:15 PM by Dave Britten.)
Post: #1
(25) Binomial Probability Distribution
This program calculates the cumulative binomial probability distribution between a given lower and upper value for r.

B(n, r, P) = Binomial probability mass of r successes in n independent trials, each with a chance of success P.

The program is built around these two formulas:

ln(B(n, 0, P)) = n * ln(1-P)

ln(B(n, r+1, P)) = ln(B(n, r, P)) + ln(n-r) - ln(r+1) + ln(P) - ln(1-P)

Logarithms are used to avoid over/underflows in intermediate calculations.

Usage:

Enter the program, and store your four inputs, n, P, MIN, and MAX, into the designated registers.

R1 = n
R2 = P
R3 = MIN (i.e. lower value of r)
R4 = MAX (i.e. upper value of r)

Press f PRGM, R/S, and wait for the cumulative probability to be returned.

A lower tail can be obtained by setting R3/MIN to 0, and an upper tail by setting R4/MAX equal to n. Set R3=R4 to compute probability mass for a single number of successes.

Program code:

Code:
01    0
02    STO 0
03    STO 5
04    RCL 1
05    1
06    RCL 2
07    -
08    ln
09    *
10    STO 7
11    LASTx
12    CHS
13    RCL 2
14    ln
15    +
16    STO 6
17    RCL 3
18    RCL 0
19    x<y
20    GTO 25
21    RCL 7
22    e^x
23    STO+ 5
24    RDown
25    RCL 4
26    x=y
27    GTO 44
28    RDown
29    CHS
30    RCL 1
31    +
32    ln
33    RCL 0
34    1
35    +
36    ln
37    -
38    RCL 6
39    +
40    STO+ 7
41    1
42    STO+ 0
43    GTO 17
44    RCL 5
45    GTO 00

Example:

100 trials, P = 40%, what is the probability that 0-50 trials succeed?

100 STO 1
.4 STO 2
0 STO 3
50 STO 4
f PRGM R/S

...wait approx. 2 minutes...

0.9832 (fix 4), or 98.32%
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(25) Binomial Probability Distribution - Dave Britten - 11-17-2019 09:14 PM



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