Reputation: 91
I tried to fit a dataset with exp decay, curve_fit raise this error "'Covariance of the parameters could not be estimated' ". Then I followed this link to try another package, still gives weird estimations. scipy curve_fit raises "OptimizeWarning: Covariance of the parameters could not be estimated"
X: array([18827., 18828., 18829., 18830., 18831., 18832., 18833., 18834.,
18835., 18836., 18837., 18838., 18839., 18840., 18841., 18842.,
18843., 18844., 18845., 18846., 18847., 18848., 18849., 18850.,
18851., 18852., 18853., 18854., 18855., 18856., 18857., 18858.,
18859., 18860., 18861., 18862., 18863., 18864., 18865., 18866.,
18867., 18868., 18869., 18870., 18871., 18872., 18873., 18874.,
18875., 18876., 18877., 18878., 18880., 18881., 18882., 18883.,
18884., 18885., 18886., 18887., 18889., 18891., 18892., 18893.,
18894., 18895., 18896., 18897., 18898., 18899., 18900., 18901.,
18902., 18903., 18904., 18905., 18906., 18907., 18908., 18909.,
18910., 18911., 18912., 18913., 18914., 18915., 18916., 18917.,
18918., 18919., 18920., 18921., 18922., 18923., 18924., 18925.,
18926., 18927., 18928., 18929., 18930., 18931., 18932., 18933.,
18934., 18935., 18936., 18937., 18938., 18939., 18940., 18941.,
18942., 18943., 18944., 18945., 18946., 18947., 18948., 18949.,
18950., 18951., 18952., 18953., 18954., 18955., 18956., 18957.,
18958., 18959., 18960., 18961., 18962., 18963., 18964., 18965.,
18966., 18967., 18968., 18969., 18970., 18971., 18972., 18973.,
18974., 18975., 18976., 18977., 18978., 18979., 18980., 18981.,
18982., 18983., 18984., 18985., 18986., 18987., 18988., 18989.,
18990., 18991., 18992., 18993., 18994., 18995., 18996., 18997.,
18999., 19000., 19001., 19002., 19003., 19004., 19005., 19006.,
19007., 19008., 19009., 19010., 19011., 19012., 19013., 19014.,
19015., 19016., 19017., 19018., 19019., 19020., 19021., 19022.])
y: array([0.25, 0.24, 0.25, 0.27, 0.27, 0.27, 0.26, 0.26, 0.26, 0.26, 0.26,
0.3 , 0.3 , 0.3 , 0.3 , 0.3 , 0.3 , 0.31, 0.31, 0.31, 0.31, 0.31,
0.31, 0.35, 0.35, 0.35, 0.35, 0.35, 0.32, 0.32, 0.32, 0.32, 0.32,
0.32, 0.32, 0.32, 0.32, 0.32, 0.32, 0.28, 0.28, 0.28, 0.28, 0.29,
0.28, 0.25, 0.25, 0.25, 0.25, 0.26, 0.25, 0.25, 0.24, 0.24, 0.24,
0.24, 0.22, 0.22, 0.23, 0.23, 0.23, 0.24, 0.24, 0.24, 0.24, 0.24,
0.24, 0.25, 0.24, 0.24, 0.25, 0.25, 0.25, 0.25, 0.25, 0.24, 0.24,
0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24, 0.24,
0.23, 0.23, 0.23, 0.25, 0.25, 0.23, 0.23, 0.23, 0.23, 0.23, 0.23,
0.23, 0.21, 0.21, 0.2 , 0.2 , 0.2 , 0.21, 0.21, 0.21, 0.21, 0.21,
0.21, 0.21, 0.21, 0.19, 0.19, 0.19, 0.2 , 0.2 , 0.2 , 0.2 , 0.19,
0.19, 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 ,
0.2 , 0.22, 0.22, 0.22, 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.19, 0.19,
0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.24, 0.25, 0.25, 0.25,
0.25, 0.26, 0.26, 0.31, 0.31, 0.31, 0.33, 0.33, 0.33, 0.32, 0.29,
0.29, 0.29, 0.29, 0.29, 0.29, 0.29, 0.29, 0.29, 0.29, 0.29, 0.29,
0.29, 0.29, 0.26, 0.26, 0.26])
Could someone guide me through, please?
Upvotes: 0
Views: 267
Reputation: 7862
This warning is telling you that one or more variables are not actually changing the fit. Based on your parameter report and the range of data, the problem is almost certainly because your initial values are so far off as to be useless starting points for refinement. It also seems very likely that the data is not explained well by an exponential decay.
To do curve fitting you must start with plausible initial values for all parameters that are not absurdly far off. Plot your data with your initial model before starting your fit.
Upvotes: 0