For each of the problems below state the purpose in your own words, specify inpu
ID: 3887099 • Letter: F
Question
For each of the problems below state the purpose in your own words, specify input that is needed, expected output, and the step by step process that will obtain the output from the input (the algorithm). In addition to these 4 items also specify test data that can be used to all the scenarios described for each problem.
Program 3: Write a process that will use the Monte Carlo method to estimate PI as described below. The Monte Carlo method to estimate probability generates a large number of points then determines how many points meet a specific condition. Consider the figure below containing a square with a circle inside of it, both of which are centered on zero
DO NOT WRITE ANY ACTUAL C++ CODE!
Explanation / Answer
Please provide detail information about the data of this question.
Answer:
An algorithm to estimate the value of |(pi|):
These points are "inside" in the unit circle.
A Monte Carlo method is a computational method to approximate a calculation of statistical measures of randomly generated large number of operations.
Monte Carlo Method is to approximate the value of (pi).
Input :
|(|pi(1)2 =|pi,|) and ,|(22 = 4|) is the area of the square( 1 X 1) .
Input;
x = 0
n=100
for i = 1, n
do
x=math.random()
y=sqrt(1-x2)
x=x+y
end
pi=4*x/n
print(pi)
Pseudocode
Set x is equal to 0
Set y is equal to some value
for i is equal to 1 to y
start loop, do
a assigned to call the function math.random()
b is assigned to call math.random()
if (a^2+b^2<1 ) then x=x+1
end start loop,
end for loop
calculate pi =(4*x/y)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.