Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Nov 27, 2009 #1
    I have data that I want to fit to both Gaussian and Lorentzian (Cauchy) distribution. I have been using Matlab's nlinfit as follows:

    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
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Lorenzian and gaussian pdf-function fitting with Matlabs nlinfit, confidence interval
  1. Gaussian functions? (Replies: 7)

  2. Fitting function (Replies: 2)

  3. Gaussian fitting (Replies: 0)

  4. Gaussian of best fit (Replies: 6)

Loading...