HP Forums
(12C) Combination/Binomial Distribution/Negative Binomial Distribution - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Combination/Binomial Distribution/Negative Binomial Distribution (/thread-6769.html)



(12C) Combination/Binomial Distribution/Negative Binomial Distribution - Eddie W. Shore - 08-31-2016 07:47 PM

Combination: Find the number of groups out of a possible set of objects. The order of objects obtained does not matter.

Store n in R1, x in R0, and p in R2. Press [ f ] [ R↓] (CLEAR PRGM), [ R/S ]
Formula: COMB(n, x) = n!/(x! * (n-x)!)

Binomial Distribution: Find number of successes (x) in a fixed number of trials (n).
Store n in R1, x in R0, and p in R2. Press [ g ] [ R↓ ] (GTO) 26, [R/S]
Formula: COMB(n, x) * p^x * (1 – p)^(n – x)

Negative Binomial Distribution: Find the number of trials (n) needed to obtain a fixed amount of successes (x).
Store x in R1, n in R0, and p in R2. Press [ g ] [ R↓ ] (GTO) 43, [R/S]
Formula: COMB(x – 1, n – 1) * p^(n -1) * (1 – p)^((x - 1) - (n – 1))

In the distribution calculations, p is the probability where 0 ≤ p ≤ 1.
Note: R3 is used as a flag, which will allowed for branching.


Code:

STEP    CODE    KEY
Combination        
01    0    0
02    44, 3    STO 3
03    45, 1    RCL 1
04    43, 3    N!
05    45, 0    RCL 0
06    43, 3    N!
07    10    ÷
08    45, 1    RCL 1
09    45, 0     RCL 0
10    30    -
11    43, 3    N!
12    10    ÷
Flag Testing        
13    45, 3    RCL 3
14    1    1
15    30    -
16    43, 35    X=0
17    43, 33, 29    GTO 29
18    45, 3    RCL 3
19    2    2
20    30    -
21    43, 35    X=0
22    43, 33, 49    GTO 49
23    33    R↓
24    33    R↓
25    43, 33, 00    GTO 00
Binomial Distribution        
26    1    1
27    44, 3    STO 3
28    43, 33, 03    GTO 03
29    33    R↓
30    45, 2    RCL 2
31    45, 0    RCL 0
32    21    Y^X
33    20    *
34    1    1
35    45, 2    RCL 2
36    30    -
37    45, 1    RCL 1
38    45, 0    RCL 0
39    30    -
40    21    Y^X
41    20    *
42    43, 33, 00    GTO 00
Negative Binomial Distribution        
43    1    1
44    44, 30, 1    STO- 1
45    44, 30, 0    STO- 0
46    2    2
47    44, 3    STO 3
48    43, 33, 03    GTO 03
49    33    R↓
50    33    R↓
51    45, 2    RCL 2
52    45, 0    RCL 0
53    21    Y^X
54    20    *
55    1    1
56    45, 2    RCL 2
57    30    -
58    45, 1    RCL 1
59     45, 0     RCL 0
60    30    -
61    21    Y^X
62    20    *
63    43, 33, 00    GTO 00

Examples:
Find the number of combinations of groups of 2 out of possible 12 objects.
12 [STO] 1, 2 [STO] 0, [ f ] [ R↓ ] (CLEAR PRGM)
Result: 66
Binomial Distribution: Toss a coin 25 times. (trails) What is the probability of tossing 10 heads? (successes) Assume a fair coin. The variables n = 25, x = 10, p = 0.5
25 [ STO ] 1, 10 [ STO ] 0, 0.5 [ STO ] 2, [ g ] [ R↓ ] (GTO) 26 [ R/S ]
Result: 0.10 (0.0974166393)
Negative Binomial Distribution: Assume a fair coin. What is the probability that the 15th tossed of heads comes on the 25th toss of the coin? x = 15, n = 25, p = 0.5
25 [STO] 1, 15 [STO] 0, 0.5 [ STO ] 2, [ g ] [ R↓] (GTO) 43 [ R/S ]
Result: 0.12 (0.1168999672)