Question: Write a program that determines the probability of tossing a coin 10 times and getting exactly 0, 1, 2, 3, etc. heads. This is the

Write a program that determines the probability of tossing a coin 10 times and getting exactly 0, 1, 2, 3, etc. heads. This is the binomial probability distribution. Store the probability in an array. If you let r be 0, 1, 2,3, etc., then you would pass r to the function.
Use a for loop. The for loop will go from 0 to 10 inclusive. Use r as the number of successes. So r will go from 0 to 10. The probability of a success is .5, and also the probability of a failure is .5.
Print out in table form, column 1=r; goes 0 to 10, and then column 2; the probability of r.
Use 4 decimal places for the probability. You know if you get the correct answers because The sum of all the probabilities is 1.0, and all probabilities are in the range of 0 to 1 inclusive.
Excel also has a binomial probability function.
Follow this link to get the formula:
http://onlinestatbook.com/2/probability/binomial.html
Store the factorials in an array.
Then when you need a factorial, like 4!, you just pull 4! from the array and use it in the calculation.
Once you are done calculating the probabilities, print out the probability array.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!