applying "tighter" bounds in scipy.optimize.curve_fit
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Fantascape Looping
--
Chapters
00:00 Question
01:37 Accepted answer (Score 23)
02:32 Thank you
--
Full question
https://stackoverflow.com/questions/4448...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy #scipy #curvefitting
#avk47
ACCEPTED ANSWER
Score 24
The ValueError of "x0 is infeasible" is coming because your initial values violate the bounds.  Printing out the parameters values and bounds will show this.  
Basically, you're setting the bounds too cleverly, based on the first refined values.  But the refined values are different enough from your starting values that the bounds for the second call to curve_fit mean the initial values fall outside the bounds.
More importantly, what leads you to "feel that 5% should be enough"? Primarily, you should apply bounds to make sure the model makes sense, and secondarily to help the fit avoid false solutions. You're calculating the bounds based on an initial fit, so I doubt there's a strong physical justification for those bounds. Why not let the fit do its job?