Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started