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[#], μ[#], σ[#]} & /@
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]
  • $\begingroup$ try putting code when possible in post. i almost missed it under a huge data list. $\endgroup$ Oct 30, 2015 at 13:30
  • 2
    $\begingroup$ 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? $\endgroup$
    – bill s
    Oct 30, 2015 at 13:31
  • $\begingroup$ I gave an answer to your privious similar question that make the whole tihng simpler. $\endgroup$ Oct 30, 2015 at 13:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.