πŸ”– Background Information

A biased coin is one where the probability of it coming up heads versus tails on a coin flip is not exactly 50-50. Suppose that we have a biased coin that has a probability of coming up heads and a probability of coming up tails. What is the expected number of heads that I would get if I flipped the coin times?

Let represent the kth coin come up heads in our sequence of flips. Then, the expectation value of the coin coming up heads () is just the probability that an independent coin flip will be heads.

Let be the number of heads after flipping the coin times. It follows then that:

The expectation value of flips coming up heads is :

By the principle of linearity:

That is to say, the expected number of heads is the probability of getting a heads multiplied by the number of times you flip the coin. Put another way, follows the binomial distribution with parameters and .

🎯 Problem Statement

Your goal for this lab is to simulate biased coin flips to determine if the result above follows:

  1. Determine the number of flips () that you want to use for your coin. I would recommend starting with and then increasing it from there.
  2. Determine the number of trials () you want want to repeat for each value of . I would recommend starting with and then increasing it from there.
  3. Determine the probability of getting heads () that you want to use for your coin. I would recommend testing a few different values.
  4. Flip your biased coin times, and record the total number of times it came up β€œheads”.
  5. Record , , , and the number of heads in a table. This is one data point for one trial.
  6. Clear your simulation and start it over. Repeat this entire process for trials and a few different values of and .

βœ… Acceptance Criteria

  • It is up to you how you want to store and display the final values.
  • At a minimum run your simulation with five different values for , three different values for , and .
  • Use the data to answer the Thought-Provoking Questions.

πŸ“‹ Dev Notes

  • Automate everything! You don’t need to manually update and record values for , , and . Instead, set up the simulation to run all of your trials () for all of your step numbers () for a given probability of heads (). Might I suggest some nested for loops?
  • This lab is very similar to This Diffusion Joke is Pretty Random. You can use your work from that lab as a reference.

πŸ–₯️ Example Output

As you run your simulation, your data might look something like this.

Number of Flips (n)Trial Number (m)Probability of Heads (p)Number of Heads
1010.54
1020.55
1030.57
1040.54
10010.7577
10020.7582
10030.7567
10040.7571

And so on…

πŸ“ Thought Provoking Questions

  1. Create some nice visualizations of your results and attach them to your discussion post (Excel or some other graphing software is totally fine). You get to decide the best way to represent your data. Be sure to label your axes and title your plots!
  2. Based on your results, do you agree that flipping a biased coin times returns an expected value of heads as outlined in the Background Information section? Why or why not?

πŸ’Ό Add-Ons For the Portfolio

N/A

πŸ“˜ Works Cited

N/A