Gaussian Curve fitting
1
0
Entering edit mode
15 months ago
satyam85cool ▴ 10

I have data where my x column corresponds to the residue position and the y axis corresponds to the entropy value. I want to do a curve-fitting on the data obtained. I was trying to fit a Gaussian curve but the curve is not fitting according to what it should look like. Can anyone suggest to me what should be an optimal way to do so?

from scipy.optimize import curve_fit

x = [18,23,95,142,154,156,157,158,258,318,367,382,484,501,522,574,681,832,943,1071,1078,1101,1133,1153,1174,1264]
y = [0.179,0.179,0.692,0.574,0.669,0.295,0.295,0.295,0.387,0.179,0.179,0.462,0.179,0.179,0.179,0.179,0.179,0.179,0.179,0.179,0.179,0.462,0.179,0.387,0.179,0.295]
x = np.asarray(x)
y = np.asarray(y)

amp1 = 100
sigma1 = 10
cen1 = 50

def Gauss(x, A, B):
    y = A*np.exp(-1*B*x**2)
    return y

parameters, covariance = curve_fit(Gauss, x, y)

fit_A = parameters[0]
fit_B = parameters[1]


fit_y = Gauss(x, fit_A, fit_B)
plt.figure(figsize=(18,10))
plt.plot(x, y, label='data')
plt.plot(x, fit_y, label="fit")
plt.legend()
plt.show()
Curve Fitting Gaussian Python • 433 views
ADD COMMENT
0
Entering edit mode
12 months ago

First of all, you should clarify for yourself (and us) on whether you are trying to fit a Gaussian function or a Gaussian distribution. These are not the same thing.

You code is attempting to fit a Gaussian function, but your data hardly looks anything like a Gaussian function. Perhaps consider a different model.

If you want to fit a Gaussian distribution to your data, I recommend you use maximum likelihood estimates with Bessel-corrected variance.

ADD COMMENT

Login before adding your answer.

Traffic: 1550 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6