<p>If you are doing chi-squared fitting, then a value for the uncertainty (or an estimate) should have been returned by the software. If not, you could perhaps manually estimate by fixing the line centre at various values, allowing the other parameters to be fitted, and seeing where the minimum chi-squared increases by 1 over the global minimum.</p>

<p>Failing that, output your spectrum as an ASCII file and fit it with something that does provide uncertainties like gnuplot.</p>

<p>Failing that, here's a rule of thumb. The line centre is determined with a precision given by the FWHM divided by the signal to noise ratio per pixel.</p>

<p>Note that none of the above take any account of uncertainties in the wavelength calibration.</p>

<p>EDIT: It appears that lmfit does estimate uncertainties. <a href="https://lmfit.github.io/lmfit-py/confidence.html" rel="nofollow noreferrer">https://lmfit.github.io/lmfit-py/confidence.html</a></p>

CC BY-SA 4.0
2019-12-02T15:03:39.963Z
I would add that the OP should take the time to learn **in detail** what the particular python tool he's using does, how it does it, and why.  I might start by telling him to use *scipy* because it's a more reliable (vetted, reviewed) package than some random GitHub tool.
Carl Witthoft
CC BY-SA 4.0
2019-12-03T02:28:11.060Z
I left [this comment](https://astronomy.stackexchange.com/questions/34136/finding-the-uncertainty-in-a-spectral-line#comment65200_34136) in review before seeing your answer. I know that strong correlations are "bad" and can cause problems especially when the quality of the fit is poor, but I don't know how to articulate that accurately.
uhoh
CC BY-SA 4.0
2019-12-02T07:10:20.737Z
2019-12-02T20:14:44.157Z
2019-12-02T20:14:44.157Z
ProfRob
<p>Currently, I am doing a lab in school on atomic spectroscopy. After taking readings of strong emission lines of various elements, I have fit the data using a Voigt Profile function from <a href="https://lmfit.github.io/lmfit-py/builtin_models.html#voigtmodel" rel="noreferrer">lmfit</a>. The function minimizes the reduced chi-squared  and returns the best fit along with fitting parameter values (center, amplitude, sigma, gamma). I am mainly interested in the center of the line profile. But, what is the uncertainty in this reported center? Or how would I report the measurement and its uncertainty. </p>

CC BY-SA 4.0
2019-12-02T15:01:46.090Z
This is really a question about statistics and not astronomy or even physics.
Carl Witthoft
CC BY-SA 4.0
2019-12-02T15:02:07.723Z
I'm voting to close this question as off-topic because it's a statistics question
Carl Witthoft
CC BY-SA 4.0
2019-12-03T02:20:20.763Z
@CarlWitthoft we can vote to close a question here if it is *off-topic in this site*, but "because it's an X question" or "is better asked elsewhere" are not good close reason. OP decides where they would like to ask it. However I'm sure that the OP would get an excellent answer in [Cross Validated SE](https://stats.stackexchange.com/) though they might be tougher on the question as written.
uhoh
CC BY-SA 4.0
2019-12-03T02:25:47.700Z
@ahayes24 have you looked at the `out.fit_report()` method shown in your linked documentation?  Search for "+/-" I think that's what you are looking for. However, I am not sure that's the whole story because when strong correlations are present (those are also included in the fit_report) then a poor fit may have worse uncertainties than the +/- might suggest. Now *that's a question for Cross Validated SE!*
uhoh
CC BY-SA 4.0
2019-12-05T00:03:43.003Z
@CarlWitthoft  Apologies for writing this question here. I assumed Astronomy had a lot of experience in spectral line fitting so I thought I would try it here. I can move it to the Cross Validated SE section and make my question clearer.
ahayes24
<spectroscopy>
Finding the Uncertainty in a Spectral Line
ahayes24
# Finding the Uncertainty in a Spectral Line

(Asked by: username_0 on 2019-12-02)

Currently, I am doing a lab in school on atomic spectroscopy. After taking readings of strong emission lines of various elements, I have fit the data using a Voigt Profile function from [lmfit](https://lmfit.github.io/lmfit-py/builtin_models.html#voigtmodel). The function minimizes the reduced chi-squared and returns the best fit along with fitting parameter values (center, amplitude, sigma, gamma). I am mainly interested in the center of the line profile. But, what is the uncertainty in this reported center? Or how would I report the measurement and its uncertainty.

**Tags:** spectroscopy
> **Comments:**
> **username_1**: This is really a question about statistics and not astronomy or even physics.  
> **username_1**: I'm voting to close this question as off-topic because it's a statistics question  
> **username_2**: @CarlWitthoft we can vote to close a question here if it is *off-topic in this site*, but "because it's an X question" or "is better asked elsewhere" are not good close reason. OP decides where they would like to ask it. However I'm sure that the OP would get an excellent answer in [Cross Validated SE](https://stats.stackexchange.com/) though they might be tougher on the question as written.  
> **username_2**: @ahayes24 have you looked at the `out.fit_report()` method shown in your linked documentation?  Search for "+/-" I think that's what you are looking for. However, I am not sure that's the whole story because when strong correlations are present (those are also included in the fit_report) then a poor fit may have worse uncertainties than the +/- might suggest. Now *that's a question for Cross Validated SE!*  
> **username_0**: @CarlWitthoft  Apologies for writing this question here. I assumed Astronomy had a lot of experience in spectral line fitting so I thought I would try it here. I can move it to the Cross Validated SE section and make my question clearer.  

---

## 1 answers

### Answer by username_3 on 2019-12-02. Score: 3

If you are doing chi-squared fitting, then a value for the uncertainty (or an estimate) should have been returned by the software. If not, you could perhaps manually estimate by fixing the line centre at various values, allowing the other parameters to be fitted, and seeing where the minimum chi-squared increases by 1 over the global minimum.

Failing that, output your spectrum as an ASCII file and fit it with something that does provide uncertainties like gnuplot.

Failing that, here's a rule of thumb. The line centre is determined with a precision given by the FWHM divided by the signal to noise ratio per pixel.

Note that none of the above take any account of uncertainties in the wavelength calibration.

EDIT: It appears that lmfit does estimate uncertainties. <https://lmfit.github.io/lmfit-py/confidence.html>

> **Comments:**
> **username_1**: I would add that the OP should take the time to learn **in detail** what the particular python tool he's using does, how it does it, and why.  I might start by telling him to use *scipy* because it's a more reliable (vetted, reviewed) package than some random GitHub tool.  
> **username_2**: I left [this comment](https://astronomy.stackexchange.com/questions/34136/finding-the-uncertainty-in-a-spectral-line#comment65200_34136) in review before seeing your answer. I know that strong correlations are "bad" and can cause problems especially when the quality of the fit is poor, but I don't know how to articulate that accurately.  

---

