- The Modern C# Challenge
- Rod Stephens
- 232字
- 2021-08-13 15:24:00
25. Monte Carlo integration
Integration is the process of calculating the area inside a region. Typically, this is the area under a curve defined by some function y = F(x). For example, in the following diagram, the goal is to calculate the shaded area under the curve in the domain -2 ≤ x ≤ 1.5:
You can use calculus to integrate the area under a curve, at least if you remember your calculus and the function is reasonably well-behaved. If you cannot apply calculus, then you can use Monte Carlo integration.
From the name and your experience with Monte Carlo approximation for π, you may be able to guess how this works. Pick a rectangle that includes the area of interest. Then, randomly generate points within the rectangle and see how many lie within the range and between the curve and the X axis. Finally, use the fraction of points in that area to estimate the area beneath the curve.
Write a program that performs Monte Carlo integration. As in the previous examples, pass the function into the method as a parameter so you can easily change it. Use your program to estimate the areas below the following functions within the indicated domains:

If you remember your calculus, make the program calculate the areas exactly and compare the calculated result and the result approximated by Monte Carlo integration.
- 432級(jí)臺(tái)階之第2級(jí)臺(tái)階
- 數(shù)學(xué)星球:人類文明與數(shù)學(xué)(萬物皆數(shù)學(xué))
- 小數(shù)學(xué)家應(yīng)該知道的數(shù)學(xué)故事
- Data Visualization:a successful design process
- 開悟:數(shù)學(xué)黑客的生活之旅
- 我的第一本趣味數(shù)學(xué)書2
- Hands-On Blockchain with Hyperledger
- 數(shù)字、代數(shù)和圖象(全彩版)
- 趣味魔方:一學(xué)就會(huì)的魔方秘笈
- 幾何公差那些事兒
- 數(shù)學(xué)建模
- 數(shù)學(xué)要素(全彩圖解 + 微課 + Python編程)
- 人大附小的課堂四聲(人大附小七彩教育成果叢書)
- 不可思議的自然對(duì)數(shù)
- 數(shù)學(xué)故事總動(dòng)員