I have data that I want to fit to both Gaussian and Lorentzian (Cauchy) distribution. I have been using Matlab's nlinfit as follows:(adsbygoogle = window.adsbygoogle || []).push({});

gaus = @(p,xdata) (p(1)/(sqrt(2*pi*p(2)))*exp(-(xdata-p(3)).^2/(2*p(2)))+min).*weights;

[g_pfit,g_residual,g_J]=nlinfit(data(:,1), data(:,2).*weights, gaus, [4030 2 -5]);

g_ci=nlparci(g_pfit,g_residual,'jacobian',J,'alpha',0.317);

loren = @(p,xdata) p(1)./(pi*p(2)*(1+((xdata-p(3))./p(2)).^2))+p(4);

[l_pfit,l_residual,l_J]=nlinfit(data(:,1), data(:,2), loren, [10030 0.5 -5 4]);

l_ci=nlparci(l_pfit,l_residual,'jacobian',l_J,'alpha',0.317);

The strange thing, however, is that my data is more like Gaussian-shaped and Gaussian curve, is by eye way more better fit. Still I get smaller errors for the width of Lorentzian fit than Gaussian (using the nlparci function).

Why would I get smaller errors for the width of the Lorentzian curve than for the width of the Gaussian curve, which is a better fit?

deccard

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB Lorenzian and gaussian pdf-function fitting with Matlabs nlinfit, confidence interval

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**