基于蒙特卡洛法的圆周率 pi 的近似解

Python73

方法简析

简单地说,当我们找不到问题的确切解时,我们可以进行随机抽样,根据统计检验找到问题的近似解。

[En]

To put it simply, when we are unable to find the exact solution of a problem, we can carry out random sampling and find the approximate solution of the problem according to the statistical test.

(\pi) 的近似求解

已知:圆的面积 (S(r)=\pi r^2)(别问我为什么),于是

[ \pi = S(1) ]

构造单位圆的外接正方形,如下图
基于蒙特卡洛法的圆周率 pi 的近似解

首先将点随机分布到正方形中(均匀分布)。当点数达到一定程度时,从统计分析的角度来看,必然存在

[En]

First randomly distribute points into the square (uniform distribution). When the number of points reaches a certain degree, from the point of view of statistical analysis, there must be

[ \frac{S_{圆}}{S_{正方形}} \approx \frac{圆内点的个数}{正方形内点的总数量} ]

因此

[ \pi = S(1) \approx 4\times\frac{圆内点的个数}{正方形内点的总数量} ]

输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长