Question
MATLAB One way to estimate the outcome of for a problem is to use a Monte Carlo simulation which uses a large number of random
MATLAB
One way to estimate the outcome of for a problem is to use a Monte Carlo simulation which uses a large number of random numbers and then compares the results of these numbers. For estimating pi, we can visualize a circle of radius 1 inside a square with a side of 2, both centered on zero.
The area of the square is 4 and the area of the circle is pi. The ratio of the area of the circle to the area of the square is pi/4. Consequently, if a large number of points (N) with x and y values varying between 1 and -1 is generated, the number of points falling inside the circle would be
Points in circle = N*pi/4
The number of points falling inside the circle can be determined by the condition x2 + y2
Use the built-in functions of length and find to determine the number of points falling in the circle for the row vectors of 10000 elements and the row vectors containing 1000000 elements. Then use these values to calculate the estimate of pi. (Do not use any built-in functions other than find, length and rand for this problem.)
The script file should generate row vectors of random numbers. You should have 2 scenarios: 10000 x-values and 10000 y-values the scenario of 1000000 x-values and 1000000-y values. Add comments to the end of this problem stating why you did not get the same value for pi for both scenarios.
-1 1 -1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started