Monte Carlo Calculates Pi Value

It is necessary to find the value of a pi number using random numbers.
Calculate a ratio between a quarter-circle area in radius R = 1 and a square in the side
a = 1 (pi/4) using
Probability of hitting the rounding area of lotteries of points in the blocking square.
required:
1. A quarter of a circle should be drawn in a single radius.
2. Create a function that draws two numbers in the field [0,1] representing (x, y) squared in size
Unit.
a. Using the rand function
3. Calculate the distance from the center and determine if the point is within the circle or not.
4. Drag N sweeps and calculate the ratio of the number of points falling in a circle to the whole
The points.
5. Draw the convergence graph of the calculated ratio depending on the number of sweepstakes

Answers (1)

Image Analyst
Image Analyst on 30 Dec 2018
Edited: Image Analyst on 30 Dec 2018
We'd be happy to help with the code for your assignment after you read this link
In the meantime, using this code from the FAQ will help you to draw a circle for your Monte Carlo pi estimation problem. How do I create a circle
Basically it's something like
for k = 1 : numPoints
% Get x,y
% Determine if (x,y) is in circle, if so increment counter
ratio(k) = numInCircle / numPoints
plot(ratio, 'b-')
drawnow;
end
Then, if you're an overachiever like me, you'll end up with something like this:
0000 Screenshot.png

Categories

Asked:

on 30 Dec 2018

Commented:

on 2 Jan 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!