Group Abstract Group Abstract

Message Boards Message Boards

0
|
30.4K Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How can I fit a gaussian function to data in Mathematica? (no distribution)

Posted 11 years ago
Attachments:
POSTED BY: Thomas H
5 Replies
Posted 11 years ago

Mathematica (I use 10.1) has a function FindPeaks that should provide good starting values for mu`

nlm = NonlinearModelFit[data, 
  A 1/(\[Sigma] Sqrt[2. \[Pi]])
    Exp[-(1./2.) ((x - \[Mu])/\[Sigma])^2], {{\[Sigma], 100.}, {\[Mu],
     FindPeaks[data, 80., 0.2, 5000.][[1, 1]]}, {A, 200}}, x]
POSTED BY: Michael Helmle
Posted 11 years ago

Ah, of course! I did not think about that. Thanks a lot :-)

POSTED BY: Thomas H
Posted 11 years ago

1st line should read: ... part of the problem is that your data are NOT very well described by a single gaussian

POSTED BY: Michael Helmle
Posted 11 years ago
POSTED BY: Michael Helmle
Posted 11 years ago

Thanks a lot!

I was not aware that I can set start values. This information is very helpful :-)

How do the start values influence the approximated values by mathematica? I have about 30 of these datasets where I do not expect sigma to change much but mu varies a lot. The point is, I want my notebook to evaluate the data automatically and I have set up everything to this point in that way. I have a formula to predict where mu should be, but if the start value affects the outcome of mu I'd rather use a different way.

POSTED BY: Thomas H
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard