Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Python Notes

Rating
-
Sold
-
Pages
5
Grade
A+
Uploaded on
24-12-2025
Written in
2025/2026

This document contains notes for artificial intelligence and machine learning and the subject is python containing module 3 notes especially questions and answers. This will help you for examinations and for students under computer science and other included branches.

Show more Read less
Institution
Course

Content preview

Randomized Approach to Problem Solving

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.

Written for

Institution
Course

Document information

Uploaded on
December 24, 2025
Number of pages
5
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$18.39
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
adithyasreekanth

Get to know the seller

Seller avatar
adithyasreekanth Mangalam College of Engineering
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
4 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions