Created
January 23, 2024 14:40
-
-
Save nicoguaro/ef0751a269d14573516ad6f9ec9fe3ff to your computer and use it in GitHub Desktop.
Polynomial fitting example in NumPy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from numpy.polynomial import Polynomial | |
rng = np.random.default_rng() | |
x = np.arange(10) | |
y = np.arange(10) + 0.01*rng.standard_normal(10) | |
p_fitted = np.polynomial.Polynomial.fit(x, y, deg=1) | |
print(p_fitted.convert().coef) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment