1. Learn
  2. /
  3. Courses
  4. /
  5. Statistical Simulation in Python

Connected

Exercise

Simulating one lottery drawing

In the last three exercises of this chapter, we will be bringing together everything you've learned so far. We will run a complete simulation, take a decision based on our observed outcomes, and learn to modify inputs to the simulation model.

We will use simulations to figure out whether or not we want to buy a lottery ticket. Suppose you have the opportunity to buy a lottery ticket which gives you a shot at a grand prize of $10,000. Since there are 1000 tickets in total, your probability of winning is 1 in 1000. Each ticket costs $10. Let's use our understanding of basic simulations to first simulate one drawing of the lottery.

Instructions

100 XP
  • Define chance_of_winning as the probability of winning the lottery.
    • Remember that 1 out of the total number of lottery tickets sold will win.
  • Set the probability list to the probabilities of receiving corresponding gains using chance_of_winning.
  • Use np.random.choice() to perform one simulation of this lottery drawing.