Post Reply 
(17BII) Binomial Probability Distribution
05-28-2015, 03:08 PM (This post was last modified: 06-15-2017 01:23 PM by Gene.)
Post: #1
(17BII) Binomial Probability Distribution
Dieter and I had been discussing improving this algorithm here, and I realized it would be easy to implement on the 17BII solver with definite loops and iterative computation/summation. So here we are. Line breaks and C-like comments added for legibility.

Example:
Find the probability of rolling a six at least 40 times when rolling a standard six-sided die 120 times.

120 N
6 1/x P1
40 L
120 H


Result:
6.41962987692E-6, or .000642% (i.e. don't wager any money on that bet)

Code:
BINPROB:
    0*(N+P1+L+H) //Set up menu variable ordering
    +0*L(B:N) //Initialize B
    +0*Σ(X:2:L:1: //Iteratively compute B=nCr(N,L)
        L(B:G(B)/X*(N-X+1))
    )
    +0*L(PΣ:L(B:G(B)*P1^L*(1-P1)^(N-L))) //Initialize PΣ with BinProb(N,L,P)
    +0*Σ(X:L:H-1:1: //Iteratively compute sum of BinProb(N,L..H,P)
        L(PΣ:PΣ+L(B:G(B)/(X+1)*(N-X)*P1/(1-P1)))
    )
    +PΣ=PΣ //Spit out result
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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