# Using the results of FindPeak in FindFit

Using FindPeak on some datapoints, I have found the positions and values of likely Gaussian peaks which form the data. The format is {x, y} and the list generated by FindPeak is here. Now I wish to incorporate these values into a FindFit function somehow. I have seen it used like this before: FindFit[MassSpecData, Model, IndependentVariable, Parameters] /. FindPeaks[MassSpecData, Gaussian], but this is somewhat vague. The model should be a sum of Gaussians, each corresponding to the peak values found.

This is my attempt

dataconfig = {A[#], μ[#], σ[#]} & /@
Range[Length@gausspeaksofdata3];
zerod = {A[#], 0, σ[#]} & /@ Range[Length@gausspeaksofdata3];
gaussian[A_, μ_, σ_, x_] =
A^2 E^(-((x - μ)^2/(2 σ^2)));

FindFit[adjusteddata, {gaussian[##, x] & @@@ dataconfig // Total,
gaussian[##] & @@@ zerod = Flatten@gausspeaksofdata3[[All, 2]], x} ,
Flatten@dataconfig, x]

• try putting code when possible in post. i almost missed it under a huge data list. – Vitaliy Kaurov Oct 30 '15 at 13:30
• Your data has hundreds of peaks. Why not try a simpler problem with only a few peaks, get things working in that case, and then generalize? – bill s Oct 30 '15 at 13:31
• I gave an answer to your privious similar question that make the whole tihng simpler. – Vitaliy Kaurov Oct 30 '15 at 13:33