Introduction
The randomized approach in computational problem-solving leverages randomness to
simulate and analyze complex problems. Unlike deterministic methods, it provides
probabilistic solutions that can simplify problem complexity and offer practical insights.
Calculating the area of a unit circle using a randomized approach involves Monte Carlo
simulation, a technique often used in numerical methods to estimate values through random
sampling.
Steps to Calculate the Area of a Unit Circle Using Monte Carlo Simulation:
1. Understand the Problem:
2
o The unit circle has a radius of 1, and its area is given by πr = π (since r=1).
o We want to estimate this area.
2. Define the Bounding Square:
o The unit circle is inscribed in a square with side length 2 (since the diameter of
the circle is 2).
o The square spans from (−1,−1) to (1,1) on a Cartesian plane.
3. Random Sampling:
o Randomly generate points (x,y) within the bounding square.
o Each x and y value is chosen uniformly between −1and 1
4. Check if Points Lie Inside the Circle:
2 2
o A point (x,y) lies inside the circle if x +y ≤ 1
5. Calculate the Ratio:
o Let Ncircle be the number of points that lie inside the circle.
o Let Ntotal be the total number of points generated.
o The ratio Ncircle / Ntotal approximates the ratio of the area of the circle to the
area of the square.
o Since the area of the square is 4, the area of the circle is approximately:
Area of Circle ≈ 4×(Ncircle / Ntotal).
6. Iterate for Accuracy:
o The more points you sample, the better the approximation.
, Program
import random
num_points = 100000
inside_circle = 0
for _ in range(num_points):
x = random.uniform(-1,1)
y = random.uniform(-1,1)
if x**2 + y**2 <= 1:
inside_circle = inside_circle + 1
area_of_circle = 4 * (inside_circle/num_points)
print(f"Estimated area : {area_of_circle}")
Example : Random Coin Flips
Problem: Estimate the probability distribution of heads in a series of coin flips.
Approach:
o Simulate repeated coin flips.
o Record outcomes and analyze the distribution of heads.
Application: Empirical analysis of probabilistic events.
Key Concepts and Examples
1. Monte Carlo Simulation (Estimating Circle Area)
o Problem: Estimate the area of a circle inscribed in a square.
o Approach:
Randomly place points within the square.
Calculate the proportion of points that fall inside the circle.
Use this ratio to estimate the circle's area relative to the square.
o Application: Solves geometric problems via probabilistic modeling.
2. Birthday Problem
o Problem: Find the probability that at least two people in a group share the
same birthday.