Monte_pi.m file underneath Homework Assignment: Formula for part B, P=(2*l)/(pi*d) Part (a): write a program using the M

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Monte_pi.m file underneath Homework Assignment: Formula for part B, P=(2*l)/(pi*d) Part (a): write a program using the M

Post by answerhappygod »

Monte_pi.m file underneath
Monte Pi M File Underneath Homework Assignment Formula For Part B P 2 L Pi D Part A Write A Program Using The M 1
Monte Pi M File Underneath Homework Assignment Formula For Part B P 2 L Pi D Part A Write A Program Using The M 1 (124.58 KiB) Viewed 31 times
Homework Assignment:
Formula for part B, P=(2*l)/(pi*d)
Part (a): write a program using the Monte Carlo algorithm (you
can start from the Monte_pi.m file we did in class) to estimate pi
for the Buffon Needle experiment, for N trials of N = 10, N = 100,
N = 1000, and N = 10000. (20 points). Turn in the program and
values from your trials.
Part (b): perform the experiment by dropping N = 1000 sticks of
length equal to the width of lines spaced evenly to get an
experimental value for pi from the formula developed in class. (20
points). Report your data from the experiment and your calculation
for pi.
***************** ********** ********* ***** ******* % PI value by Monte-Carlo Method*********** % By Mahesha MG ******** clc; n=input('Number of points: '); x=rand(n,1); y=rand(n, 1); % figure('color', 'white'); hold all axis square; x1=x-0.5; y1=y-0.5; %cirle has centre at (0.5,0.5) r=x1.^2+y1.^2; m=0; %Number of points inside circle for i=1:n if r(i)<=0.25 m=m+1; % plot(x(i),y(i), 'b.'); else % plot(x(i),y(i), 'r.'); end end m/(0.25*n)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply