0

在我的项目中,我有一条最适合我使用的点的线np.polyfit。有了这个,我想计算返回的最佳拟合线和地平线之间的度数。就好像最佳拟合线中的第一个点位于原点一样。我的一些误解来自对 polyfit 返回的混淆。我怎样才能得到最好的角度?

4

1 回答 1

2
import numpy as np
# simulate some data:
x = np.arange(10, dtype=np.float)
b = 1.5
y = 2 * x + b
# fit the data with a 1st degree polynomial
# (1st degree because poster mentions "best-fit *line*"):
cf = np.polyfit(x, y, 1)
np.rad2deg(np.arctan(cf[0]))

观看https://www.brightstorm.com/math/precalculus/advanced-trigonometry/angle-inclination-of-a-line/关于多项式的系数(cf[0] = m 在视频中) 与角度有关。

于 2017-07-02T10:26:39.873 回答