Binomial Probabilities
To compute the probability of a certain number of outcomes (k) of a
certain number of attempts (n), given that the probability of that
outcome is p, is:
nCk *
pk * (1-p)(n - k)
Where nCk means the number of combinations
of n taken k at a time. This is:
n!
k! (n - k)!
Using a Javascript Function to Compute
It is easy to write a small web page that allows the user to type in
certain values in a text field and make a small program in
Javascript to compute a result based on these values.
First define a form and some text fields to hold the values of n, k and p:
Then define a script which is called when the user presses the button. To
see how this works, View the page source. Save this page and see if you
can write your own web page that can compute the probability of
k or more outcomes. To check your work,
the probability of 3 successes of 5 attempts (with p=.6) is 0.346
and the the probability
of 3 or more is .683. To see javascript
errors type "javascript:" in the web page location of your browser.
See if you can use your web page to answer question 25 of the
Chapter 4 Quiz