Curve / peak fitting

For the discussion of the sciences. Physics problems, chemistry equations, biology weirdness, it all goes here.

Moderators: gmalivuk, Moderators General, Prelates

masher
Posts: 821
Joined: Tue Oct 23, 2007 11:07 pm UTC
Location: Melbourne, Australia

Curve / peak fitting

Postby masher » Thu Oct 21, 2010 4:45 am UTC

Hi All

I'm currently trying to model some data. I would like to fit the peak using a single peak of whatever profile I end up choosing.

The data pretty much follows a lognormal curve, but is a little different...
I'm currently fitting the data with the following model:
[math]f(x) = y_0 + \frac{a}{x} \exp \left ( -\frac{1}{2} \left ( \frac{\ln \left (\frac{(x-b)}{c} \right )}{d} \right )^2 \right )[/math]
which is a slight modification of a standard log-normal curve.

The best fit I can get is this:
curve.png

I only need to fit the data from about 25 and above.

Are there any suggestions for additional parameters that can improve my model? I would like to stay away from adding additional peaks.

User avatar
Meteorswarm
Posts: 979
Joined: Sun Dec 27, 2009 12:28 am UTC
Location: Ithaca, NY

Re: Curve / peak fitting

Postby Meteorswarm » Thu Oct 21, 2010 4:57 am UTC

A few thoughts:

You could pull the standard trick from chemistry and try to rearrange the equation in such a way that your plot is linear to some degree, allowing you to extract a parameter or two from the slope or intercepts.

The more serious approach you might consider is performing a non-linear best-fit on this, optimizing over all the parameters. Software like Octave will help; non-linear least squares is a commonly taken approach.
The same as the old Meteorswarm, now with fewer posts!

tckthomas
Posts: 131
Joined: Thu Aug 05, 2010 2:17 am UTC

Re: Curve / peak fitting

Postby tckthomas » Thu Oct 21, 2010 6:44 am UTC

squeeze the data into wolfram alpha and let the super computer do the job for you? well, that might not work if wolfram alpha has a input length limit. i don't know any way to help, sorry.

User avatar
eta oin shrdlu
Posts: 451
Joined: Sat Jan 19, 2008 4:25 am UTC

Re: Curve / peak fitting

Postby eta oin shrdlu » Thu Oct 21, 2010 8:06 am UTC

Do you have any theoretical basis for choosing a fitting model? Fitting a single curve is easy, but if you want a robust model for fitting a family of curves it helps to know why the data looks the way it does.

As for your specific curve, to the right of the peak it looks like a nice clean exponential (linear on a semi-log plot), over a couple decades of data. To the left of the peak it actually looks pretty linear over the region you're interested in (eventually it tapers off rather than go negative, but you say you don't care about that part). So you can get a pretty good fit by mixing a linear curve with an exponential. With a five-parameter fit of the form[math]y(x) = \left(u(x)^{-n}+v(x)^{-n}\right)^{-1/n}[/math]with[math]u(x)=\exp(a-bx)[/math][math]v(x)=cx-d[/math]I can get something that looks like this:
fit.png
fit.png (8.79 KiB) Viewed 973 times


Here u(x) is the exponential tail, v(x) is the linear short-time behavior, and y(x) is a function that smoothly approximates the minimum of these two functions; the exponent n (for the fit here I used n=9) governs how tightly it matches the minimum.

masher
Posts: 821
Joined: Tue Oct 23, 2007 11:07 pm UTC
Location: Melbourne, Australia

Re: Curve / peak fitting

Postby masher » Thu Oct 21, 2010 10:54 pm UTC

eta oin shrdlu wrote:Do you have any theoretical basis for choosing a fitting model? Fitting a single curve is easy, but if you want a robust model for fitting a family of curves it helps to know why the data looks the way it does.


I'm modelling the the energy distribution coming out of a synchrotron wiggler. I have theoretical curves, and now I'm trying to bend the fits from those data to match experimental results.

eta oin shrdlu wrote:So you can get a pretty good fit by mixing a linear curve with an exponential. With a five-parameter fit of the form[math]y(x) = \left(u(x)^{-n}+v(x)^{-n}\right)^{-1/n}[/math]with[math]u(x)=\exp(a-bx)[/math][math]v(x)=cx-d[/math]


Nice. I don't know it it's a typo, or if I just can't get it to work, but I used [imath]u(x)=a \exp(-bx)[/imath]. My [imath]n[/imath] refined to be about 6.5.


I did have a go at putting a pseudo-Voight peak on top, and it works very nicely, but I think I may have lucked in with some of the parameters, and I could get away with equating things that shouldn't probably be equated. Additionally, yours fits the decay curve better.

I'll need to go away and think about the physical nature of everything...

.

Is that a general method for combining what is essentially a piecewise function into a single function? I'll have to remember that.

User avatar
eta oin shrdlu
Posts: 451
Joined: Sat Jan 19, 2008 4:25 am UTC

Re: Curve / peak fitting

Postby eta oin shrdlu » Fri Oct 22, 2010 1:01 am UTC

masher wrote:I'm modelling the the energy distribution coming out of a synchrotron wiggler. I have theoretical curves, and now I'm trying to bend the fits from those data to match experimental results.
What sort of curves do you expect?
masher wrote:Nice. I don't know it it's a typo, or if I just can't get it to work, but I used [imath]u(x)=a \exp(-bx)[/imath]. My [imath]n[/imath] refined to be about 6.5.
Same thing; [imath]\exp(a-bx)=\exp(a)\exp(-bx)[/imath], so you've just pulled the constant term out of the exponential.
masher wrote:Is that a general method for combining what is essentially a piecewise function into a single function? I'll have to remember that.
It's related to the harmonic mean (and the class of power means), but really it's just noticing that for a,b>0, m(a,b)=1/(1/a+1/b) is smaller than either a or b, approaching a in the limit a<<b and vice versa. (This is just the formula for the parallel combination of resistors.) So m(a,b) acts like min(a,b) except where a~b. Trying this gives too broad a transition region for your curve, though, so I raise the inputs a and b to some large power n first to better discriminate them, then raise the output to the power 1/n at the end.


Return to “Science”

Who is online

Users browsing this forum: No registered users and 11 guests