hellowill89 - 3 months ago 17

Python Question

In my project, I have a best-fit line for some points which I got using

`np.polyfit`

Answer Source

```
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]))
```

It may be useful to watch https://www.brightstorm.com/math/precalculus/advanced-trigonometry/angle-inclination-of-a-line/ on how coefficients of the polynomial (cf[0] = m in the video) relate to the angle.