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.
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.


Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









