First of all, thanks @snake_charmer for your answer , but I found an easier way to solve the problem using curve_fit from scipy.optimize
I customize my sample data using curve_fit , which gives me my best suitable parameters. What this also gives me is an estimate of the covariance of the parameters. Diagonals of the same parameter provide variance of the parameter estimate. To calculate one standard error of the deviation in the parameters, we can use np.sqrt(np.diag(pcov)) , where pcov is the covariance matrix.
def fitfunc(M,p1,p2): N = p1+( (M)*p2 ) return N
The above fit function that I use for data.
Now to put data using curve_fit
popt_1,pcov_1 = curve_fit(fitfunc,logx,logn,p0=(10.0,1.0),maxfev=2000) p1_1 = popt_1[0] p1_2 = popt_1[1] sigma1 = [np.sqrt(pcov_1[0,0]),np.sqrt(pcov_1[1,1])]
So just by using the square root the diagonal elements of the covariance matrix, I can obtain the 1 sigma confidence lines.

source share