hellowill89 - 8 months ago 52

Python Question

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

`np.polyfit`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

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.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**