Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider calculating the area of the unit circle (radius=1, centre at the origin) with random numbers. Write a function 'MCint_pi()' which takes the number
Consider calculating the area of the unit circle (radius=1, centre at the origin) with random numbers. Write a function 'MCint_pi()' which takes the number of attempts as single input parameter and draws two floating-point random numbers, each in the interval [-1,+1] for the x- and y-coordinate value, respectively (i.e. points uniformly distributed in the square). Count the number of circle hits, M, i.e. fulfilling the condition 2 d = x + y 1 and get the area as square 2 x 2 times fraction of hits within circle M/N with N attempts. Return the calculated area value. Note, any manual return of a value of pi will be moderated to zero marks. Answer: (penalty regime: 10, 20, ... %) 1 Check
Step 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