机器之心

选自medium

机器之心编译

机器之心编辑部

杀鸡用牛刀,我们用机器学习方法来算圆的面积。

询问任何人圆的面积是多少,他们都会告诉你不就是��r⊃2;吗。但如果你问他们为什么,他们很可能并不知道。

这是因为圆的面积公式的证明在大多数情况下要么不直观,不令人满意,要么充斥着积分等高级数学概念。

借鉴统计学习和机器学习的核心原理,我们可以使用蒙特卡罗模拟和多项式/二次回归来创建基于计算的方法,以找到圆的面积公式。

在不使用任何数学运算的情况下得出圆的面积,我们使用了蒙特卡罗方法。从探索不规则形状的面积到预测股票市场的情况,都用到了蒙特卡罗方法。该方法的核心思想是引入随机性,并测量系统对其作出的反馈,甚至可以在不了解系统原理的情况下获得有效信息。

在使用蒙特卡罗来近似圆的面积时,我们先生成一些随机坐标点 ,这两个方向的坐标都是从负半径值到正半径值的均匀分布绘制得到的。我们在圆中放入 250,000 个这样的坐标点,如中心极限定理:

#A counter for the number of points in the circle

in_circle = 0

for i in range:

#Generate an x and y coordinate from a uniform distribution bounded by a tangent box

xcoor = np.random.uniform

ycoor = np.random.uniform

#If the point is inside the circle, add one to in_circle

if xcoor**2 + ycoor**2 < radius**2:

in_circle += 1

#Get the fraction of the points that were inside the circle

area_frac = in_circle/num_points

#Append the approximated area and the radius

areas.append))

radii.append

而下一步就是写一个拟合数据的二次项模型: #note - tqdm is just a progressbar

#Propose two path for the coefficient:

up_coef = coef + learning_rate #Move up

down_coef = coef - learning_rate #Or move down

#Store the predictions for a model using parameters up_coef and down_coef

up_pred = []

down_pred = []

#For each radius value in the previously created list radii:

for r in radii:

#Append the model using up_coef's and down_coef's prediction

up_pred.append)

down_pred.append)

#Find the MAE. Both are converted to NumPy arrays for easy operation.

up_coef_mae = np.abs-np.array).mean

down_coef_mae = np.abs-np.array).mean

#If moving the coefficient down yields a lower MAE:

if down_coef_mae < up_coef_mae:

#Set it equal to down_coef

coef = down_coef

#Otherwise or equal MAE:

else:

#Set it equal to up_coef

coef = up_coef

当我们查看训练的 coef 值时,可以看到它等于π:

print[:5]) #first four digits of coefficient

[Output]: '3.141'

当然,计算圆面积的公式很好记就是��r⊃2;。无需使用微积分中的任何复杂的数学方法或其他证明,我们就能找到它的公式,并找到一种使用蒙特卡洛模拟和二次回归找到��值的方法。使用这种思路就可以找到计算圆面积的方法——当然也可以找到任何图形的面积计算公式——椭圆、心形、二维的乌龟形状——只要参数可以说明它的轮廓。

近年来,计算机已经接手开始解决复杂的高可变数学问题,计算圆面积只是其中的一个简单的示例。如果想要更复杂、更具开创性的,那当然是四色定理了。这是第一个由计算机先生成证明,又被数学家广泛接受的成果。

借助计算机,人类可以探索以往无法尝试进入的,极其复杂的数学领域。

原文链接:https://medium.com/swlh/finding-the-formula-for-circle-area-without-using-any-math-898cbee70253

机器之心联合 AWS 开设线上公开课,通过 6 次直播课程帮助大家熟悉 Amazon SageMaker 各项组件的使用方法,轻松玩转机器学习。

6 月 2 日 20:00,AWS解决方案架构师尹振宇将带来第 3 课,详解如何利用SageMaker Operator简化Kubernetes 上的机器学习任务管理。

点击或识别二维码,立即预约直播。


1.《求圆面积 不用任何数学方法,如何计算圆面积》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。

2.《求圆面积 不用任何数学方法,如何计算圆面积》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。

3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/guonei/399400.html