Skip to content

Instantly share code, notes, and snippets.

@nicoguaro
Created January 23, 2024 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoguaro/ef0751a269d14573516ad6f9ec9fe3ff to your computer and use it in GitHub Desktop.
Save nicoguaro/ef0751a269d14573516ad6f9ec9fe3ff to your computer and use it in GitHub Desktop.
Polynomial fitting example in NumPy
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