Question: Python Please! 8.5.2 Area Computing by Throwing Random Points Think of some geometric region G in the plane and a surrounding bounding box B with
Python Please!

8.5.2 Area Computing by Throwing Random Points Think of some geometric region G in the plane and a surrounding bounding box B with geometry [xL, xHyL, yH]. One way of comput- ing the area of G is to draw N random points inside B and count how many of them, M, that lie inside G. The area of G is then the fraction M/N (G's fraction of B's area) times the area of B, (H-L)(H-yL) Phrased differently, this method is a kind of dart game where you record how many hits there are inside G if every throw hits uniformly within B. Below is an example to use this approach to calculate the area of integral of f(x) from a to b. def MCint area(f, a, b, n, m): below 0 # counter for no of points below the curve for i in range(n): xrandom.uniform(a, b) y- random.uniform(0, m) if y
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
