Last active
          June 7, 2018 14:24 
        
      - 
      
 - 
        
Save taldcroft/5014170 to your computer and use it in GitHub Desktop.  
    Investigating `scipy.optimize.curve_fit` covariance output
  
        
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
@taldcroft
I had this gist pop up as a search result while I was looking for something else concerning
curve_fit. However, I wonder, isn't theabsolute_sigmaflag exactly what you need (and the only thing you need) in the case you're describing above?results for example in
As you can see,
perrdoes get bigger, if I usesigma=100*s- but you have to set theabsolute_sigmaflag toTrue.In the third call you can see that
perris (more or less) the same as in the first two calls tocurve_fit. This is because thesigmaargument's values are supposed to be weights in standard deviations of theydata and we're usingnp.random.normalto generate these. Therefore,absolute_sigma=Truehas no effect in this case because absolute and relativesigmaweights are the same value. (The small remaining difference0.01243135vs0.01266702is due to the low number of points, which makes the standard deviation of the points deviate a little from the "real" standard deviation used to generate them.)Conclusion: if one is using the
sigmaargument ofcurve_fitfor absolute errors instead of weights (standard deviations) one should useabsolute_sigma=Trueforperrto be appropriately scaled to these errors. More information in the docs forcurve_fitas well https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html