Welcome to the Probability Simulation

Probability provides a way to discover how likely it is that some given action is going to result in a given outcome. Such discover involves calculating the number of possible ways that a given event might unfold. If a coin is flipped, the outcome of the flip is that the coin will be that the coin lands on the head or the tails side. Each side is one of two possibilities, which translates to a probability of 0.5. Understanding that the probability does not change with the number of tosses is important. Because the coin has landed on the head side ten times in a row does not mean that it is therefore more likely to land on the head side. As evident as such notions tend to be after studying statistics, it remains that millions of people still make important decisions using assumptions that statistics does not substantiate.

This application is modeled after the Game show Let’s Make a Deal where there are three doors and the contestant gets to pick a door. After they pick a door, a door that does not contain the prize is opened and the host allows the contestant to either stay with the door that they initially picked or to choose the other door. Using probability, we know that they contestant has a better chance at winning if they change doors instead of staying with the door that they initially picked. This may not be initially intuitive, but by extending it to the case where there are 10, 20 or 1 million doors can help understand the logic.

You can change this lab in several ways:

  • Change the text that is displayed in the statistics fields.
  • When opening doors in the doorClicked() function, change it so that there is a 25% chance of opening the door instead of 50%.
  • Adjust the duration of the timer between games.
  • Adjust the code to open all but 3 or 4 doors when at least 6 doors are on the stage. How does this affect the probability o fpicking the correct door?
  • Make it so you can run multiple trials with one click.
  • Write a function to test that the random numbers generated are fair (one number does not get a significant number more occurrences than the other numbers.) Try generating 1000, 10000, 100000 values and see how the amounts compare.