Skip to content

Instantly share code, notes, and snippets.

Created Jan 31, 2019
What would you like to do?
Fit all the sines
from numpy import sin
from scipy import optimize
sine = lambda t, p: p[0] * sin(1. / p[1] * t + p[2]) + p[3]
sinefit = lambda t, y, ye, p0, **kwargs: optimize.leastsq(lambda p, t, y, ye: (sine(t, p) - y)/ye, p0, args=(t, y, ye), **kwargs)[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment