# Fitting two separate curves to a graph consistently?

I have a set of graphs with a large primary peak and a secondary peak that intersects the first and I want to fit two curves (one per peak) and find the point at which the two curves intersect for thresholding reasons.

The problem is that the way the curves are fit has to be exactly repeatable and algorithmic in order to reduce my error margin for comparison purposes. Is there a curve fitting method that returns a set of curves, one for each peak found?

If it helps, I'm writing this in IDL.

-

You can fit your data to a functional form you choose. One possibility would be the sum of two Gaussian distributions plus a background: $n(x)=a+b \exp((x-\mu_1)^2/\sigma_1^2)+c \exp((x-\mu_2)^2/\sigma_2^2)$ You can use whatever peaked function you like in place of the Gaussian. Then feed it to a multidimensional minimizer to estimate the parameters. Chapter 10 of Numerical Recipes or any numerical analysis text will give you information. This will be repeatable, but the intersection point may well depend upon the functional form you choose.