Let us design a Monte Carlo method to estimate the area of the shadow region under the green function y = ex when x is from 0 to r. As shown in the following figure, r is a variable (r> 0) for range. Please write a Python program named "A1Q1_MonteCarlo.py" to implement your designed Monte Carlo method. In the first line of your code, please write "n=10000" to define n as the experiment number of random sampling. Finally, please print out the estimated area for different range variables with the following format: When r=1, estimated shadow area is xxx When r=2, estimated shadow area is xxx When r=9, estimated shadow area is xxx When r=10, estimated shadow area is xxx [Hint]: You may need to use a loop for different range variables r and generate random sampling points automatically based on different range variables r.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

Let us design a Monte Carlo method to estimate the area of the shadow region under the green function y = ex when x is from 0 to r. As shown in the following figure, r is a variable (r> 0) for range.

Please write a Python program named "A1Q1_MonteCarlo.py" to implement your designed Monte Carlo method. In the first line of your code, please write "n=10000" to define n as the experiment number of random sampling. Finally, please print out the estimated area for different range variables with the following format:

When r=1, estimated shadow area is xxx

When r=2, estimated shadow area is xxx

When r=9, estimated shadow area is xxx

When r=10, estimated shadow area is xxx

[Hint]: You may need to use a loop for different range variables r and generate random sampling points automatically based on different range variables r.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning