Question

This problem is also a Monte Carlo simulation, but this time in the continuous domain: must use the following fact: a circle inscribed in a unit square

has as radius of 0.5 and an area of ?∗(0.52)=?4.π∗(0.52)=π4.

Therefore, if you generate num_trials random points in the unit square, and count how many land inside the circle, you can calculate an approximation of ?

For this problem, you must create code in python

(A) Draw the diagram of the unit square with inscribed circle and 500 random points, and calculate the value of ?

(B) Without drawing the diagram, calculate the value of ? you
would get from 10^{5} trials.

(C) After completing (B), try to get a more accurate value for ? by increasing the number of trials.The results will depend on your machine

Answer #1

Pi value changes as the INTERVAL is changed

import random

INTERVAL=10000

circle_points = 0

square_points = 0

for i in range(0,INTERVAL * INTERVAL):

rand_x = (random.randint(0,1000) % (INTERVAL + 1)) / INTERVAL

rand_y = (random.randint(0,1000) % (INTERVAL + 1)) / INTERVAL

origin_dist = rand_x * rand_x + rand_y * rand_y

if (origin_dist <= 1):

circle_points=circle_points+1

square_points=square_points+1

pi = (4 * circle_points) / square_points

print("Final Estimation of Pi = " + pi)

A Monte Carlo simulation is a method for finding a value that is
difficult to compute by performing many random experiments. For
example, suppose we wanted to estimate π to within a certain
accuracy. We could do so by randomly (and independently) sampling n
points from the unit square and counting how many of them are
inside the unit circle (assuming that the probability of selecting
a point in a given region is proportional to the area of the
region)....

You are using a Monte Carlo simulation to estimate the area of
shape inside a unit square by taking n sample points. How big does
n have to be in order for the estimate to be within about ±0.01 of
the correct answer?
I believe this has to do with binomial distribution.

Problem 4) In 2012, the percent of American adults who owned
cell phones and used their cell phone to send or receive text
messages was at an all-time high of 80%. Assume that 80% refers to
the population parameter π. More recently in 2016, a polling firm
contacts a simple random sample of 110 people chosen from the
population of cell phone owners. The firm asks each person “do you
use your cell phone to send or receive texts? Yes...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 4 minutes ago

asked 6 minutes ago

asked 45 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 3 hours ago

asked 3 hours ago

asked 3 hours ago

asked 3 hours ago

asked 4 hours ago