Created
January 31, 2019 11:26
-
-
Save j-faria/576e18f0c4f5f2dc43bf2767b164286e to your computer and use it in GitHub Desktop.
Fit all the sines
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
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