Exercise

Wrong deterministic calculation

In this exercise and the next, you'll play around with the pi calculations from the video to further understand the importance of each step in the simulation process.

Recall that the simulation to find pi generates random points \((x, y)\) where \(x\) and \(y\) are between -1 and 1, as shown in the graph below.

A graph of a circle inside a square with randomly sampled points

What if you incorrectly changed the deterministic calculation where you check whether a point should be added to circle_points? How will this affect the final result? You'll see from the wacky value you get for pi that correctly specifying deterministic calculations is essential for Monte Carlo simulations!

random has been imported for you.

Instructions

100 XP
  • Increment circle_points for any point with a distance from origin of less than 0.75 (rather than a distance of one as demonstrated in the video).