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.
![](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fd00c312f-6672-4168-86c3-f4f2934a1626%2F28696f8d-e13b-426c-bd95-96e1856a0ec4%2F0294pge_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)