# Pi_value.m - Monte-Carlo simulations of Pi clc close all...

• Homework Help
• 1

This preview shows page 1. Sign up to view the full content.

% Monte-Carlo simulations of Pi clc; close all; clear all; % N = Number of trials % T = Total Number of points inside the square % c = Number of points in Circle % r = Radius of circle % P = Approximate value of "pi" i=input('Insert value of i: '); N = 10^i; r = 1; T = 1e4 ; P = zeros(1,N); for k = 1:N Px = r*rand(1,T); % Random x-Coordinate Py = r*rand(1,T); % Random y-coordinate r1 = sqrt(Px.^2+Py.^2); c = 0; for i=1:T if (r1(i)<=r) % Check- if the point lies inside the circle c = c+1; % If Yes, count the number of points end end P(k) = 4*(c/T); end m = mean(P);
This is the end of the preview. Sign up to access the rest of the document.
• Fall '15
• Monte Carlo method, Ly, (1,T);

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern