Question: 1 . 4 Problems Part 4 1 . Buffon's needle problem is another way to estimate the value of pi with random numbers. The

1.4 Problems Part 4
1. Buffon's needle problem is another way to estimate the value of \pi
with random numbers. The goal in this Monte Carlo estimate of \pi
is to create a ratio that is close to 3.1415926... similar to the example with darts points lying inside/outside a unit circle inside a unit square.
Buffon's needle for parallel
lines
In this Monte Carlo estimation, you only need to know two values:
the distance from line 0, x=[0,1]
the orientation of the needle, \theta =[0,2\pi ]
The y-location does not affect the outcome of crosses line 0 or not crossing line 0.
a. Generate 100 random x and theta values remember \theta =[0,2\pi ]
b. Calculate the x locations of the 100 needle ends e.g. xend=x\pm cos\theta
_since length is unit 1.
c. Use np.logical_and to find the number of needles that have minimum xend min<0
and maximum xend max>0
. The ratio xend min<0 and xend max>0number of needles=2\pi
for large values of number of needles
.
2. Build a random walk data set with steps between dx=dy=1/2 to 1/2 m
. If 100 particles take 10 steps, calculate the number of particles that move further than 0.5 m.
Bonus: Can you do the work without any for-loops? Change the size of dx and dy to account for multiple particles.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!