Question:
Gaussian peak fitting for spectroscopic data?
Raven
2011-09-20 12:28:39 UTC
I have some data from a hydrogen spectroscopy experiment in my physics lab. The data appears normal. I need to find the mean of the data to determine the actual wavelengths of the hydrogen lines. My professor suggested I do a Gaussian fit, but after hours of searching online, I still don't really know how to do that. Can anyone please send me in the right direction?

I don't have easy access to Matlab, for running scripts, but I do have Scilab.

If you need to see it, some of my data can be found here:
https://docs.google.com/spreadsheet/ccc?key=0AiimIHj9wt3-dGkxaUlteUFFckdDTVhBWmNDZVMweXc#gid=8

Each sheet actually contains two peaks, a deuterium peak and a hydrogen peak. If you can help me just fit one peak, I can hopefully get the rest myself.
Four answers:
anonymous
2011-09-23 02:16:59 UTC
There are quite a few experimental methods in physics and chemistry that produce data with peaks, so it's a popular problem and there are many programs that can help with it.

If you just need to get things done (instead of gaining deeper understanding of underlying nonlinear fitting algorithms) use one of such programs.

Several scientific plotting and data analysis programs have functions for fitting Gaussian and other peaks. There are also programs specialized in peak fitting.

I don't know any good and unbiased comparison of such software. Wikipedia has a more general list:

http://en.wikipedia.org/wiki/List_of_numerical_analysis_software

and category specific to curve fitting software (but category is not as informative as list):

http://en.wikipedia.org/wiki/Category:Regression_and_curve_fitting_software

I'm developing one of the most popular peak fitting programs ( http://fityk.nieto.pl ) and I think it's good, but obviously I'm biased.
anonymous
2016-11-15 09:43:58 UTC
Gaussian Fit Matlab
?
2011-09-20 15:31:31 UTC
In your case you need to fit a gaussian with 4 parameters. These are DC offset (the background value), location of peak, height of peak above the background, and standard deviation. Fitting a gaussian is not so trivial. One can take the log of the data and fit a quadratic which is the same form as fitting the gaussian and which may work for your data, but this has a couple of problems: One is that the wrong error is being minimized, since you minimize the square of the difference of logs in this case, and the other is that you would have to eyeball the dc offset and then deal with what happens when sample values are close to zero above this dc offset, which would give negative infinity for the log values. You could just subtract out the dc offset and then only use relative height values that were > say 0.1. You would then be fitting using only data that was significantly above the baseline. I'm assuming that you can work out how to fit a quadratic.



The objective error function you actually need is E(offset,gain,mean,sigma) = y_i - (offset+gain*exp(-(x_i - mean)^2 / (2*sigma))), where x_i and y_i is your data.



The only way to properly fit the gaussian is by using non-linear least squares. This can be done in matlab with the lsnonlin function, although I understand that you do not have access to matlab.



Essentially you have to adjust the parameters {offset, gain, mean and sigma} to do gradient descent on your sum of squared error Sum{E()^2} over the sample set {x_i, y_i}. There is no magic solution. Gauss-newton iteration is probably sufficient for this problem.
anonymous
2016-11-09 13:12:32 UTC
Gaussian installation this technique tries to extra healthful a variety of of Gaussians to the information. to boot to the variety (which will desire to be ``gaussian''), the kind of Gaussians to extra healthful could desire to be provided. added parameters is often provided to help the installation recurring. for each Gaussian extra healthful, there are 3 parameters used to describe it: the amplitude, the X-height place, and the completed width at 0.5 the peak amplitude (FWHM). Or as an equation: the place is the amplitude of the ith Gaussian; , the peak place; and , the FWHM. The ensuing curve stands out as the sum of the N it fairly is waaaaaaay above my head, yet i'm hoping this enables? Gaussians: observe that if any of the provided Gaussian words are detrimental, they are going to be held fastened in the time of the installation. while a extra healthful is discovered, this technique returns 3 coefficients for each Gaussian extra healthful and the chi-sq. value of the extra healthful. 6.2 proscribing and showing suits


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...