<p>You must explicitly request uncertainties.</p>
<p><code>fitter = fitting.LevMarLSQfitter(calc_uncertainties=True)</code></p>
<p>Read the docs:
<a href="https://docs.astropy.org/en/stable/api/astropy.modeling.fitting.LevMarLSQFitter.html" rel="nofollow noreferrer">https://docs.astropy.org/en/stable/api/astropy.modeling.fitting.LevMarLSQFitter.html</a></p>

CC BY-SA 4.0
2022-08-10T13:07:51.930Z
It's a perfectly clear, concise answer. I added a link to the documentation, which is quite clear too.
ProfRob
CC BY-SA 4.0
2022-08-09T12:49:15.013Z
2022-08-10T13:09:15.037Z
2022-08-10T13:09:15.037Z
Ed Behn
<p><a href="https://i.sstatic.net/szZYn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/szZYn.png" alt="enter image description here"></a></p>

<p>So I am using Astropy's basic <strong>models.Gaussian1D</strong> model and a <strong>fitter = fitting.LevMarLSQfitter()</strong> to fit 3 Gaussian pulses with some added random noise. The fit is good, but when I type</p>

<p><strong>fitter.fit_info</strong>, according to  <a href="https://docs.astropy.org/en/stable/api/astropy.modeling.fitting.LevMarLSQFitter.html" rel="nofollow noreferrer">documentation</a> here, it should automatically calculate covariance matrix and add it to the fit_info, but it doesn't, <strong>fit_info['param_cov']</strong> is simply <strong>None</strong>. What is going on?</p>

CC BY-SA 4.0
2019-07-18T23:16:08.907Z
Does [this code](https://github.com/astropy/astropy/blob/cc2458b9ab3ea2af191acb5cc0ea1789e8d2a73f/astropy/modeling/fitting.py#L895) shed any light?
Mike G
CC BY-SA 4.0
2022-08-10T13:09:53.017Z
The documentations says: "Parameters calc_uncertainties bool
If the covarience matrix should be computed and set in the fit_info. Default: False" 
  https://docs.astropy.org/en/stable/api/astropy.modeling.fitting.LevMarLSQFitter.html
ProfRob
<python><software><astropy>
Covariance matrix not calculated when fitting gaussians?
MinYoung Kim
# Covariance matrix not calculated when fitting gaussians?

(Asked by: username_0 on 2019-07-18)

[![enter image description here](https://i.sstatic.net/szZYn.png)](https://i.sstatic.net/szZYn.png)

So I am using Astropy's basic **models.Gaussian1D** model and a **fitter = fitting.LevMarLSQfitter()** to fit 3 Gaussian pulses with some added random noise. The fit is good, but when I type

**fitter.fit\_info**, according to [documentation](https://docs.astropy.org/en/stable/api/astropy.modeling.fitting.LevMarLSQFitter.html) here, it should automatically calculate covariance matrix and add it to the fit\_info, but it doesn't, **fit\_info['param\_cov']** is simply **None**. What is going on?

**Tags:** python, software, astropy

> **Comments:**
> **username_1**: Does [this code](https://github.com/astropy/astropy/blob/cc2458b9ab3ea2af191acb5cc0ea1789e8d2a73f/astropy/modeling/fitting.py#L895) shed any light?  
> **username_2**: The documentations says: "Parameters calc_uncertainties bool If the covarience matrix should be computed and set in the fit_info. Default: False"    https://docs.astropy.org/en/stable/api/astropy.modeling.fitting.LevMarLSQFitter.html  

---

## 1 answers

### Answer by username_3 on 2022-08-09. Score: 3

You must explicitly request uncertainties.

`fitter = fitting.LevMarLSQfitter(calc_uncertainties=True)`

Read the docs:
<https://docs.astropy.org/en/stable/api/astropy.modeling.fitting.LevMarLSQFitter.html>

> **Comments:**
> **username_2**: It's a perfectly clear, concise answer. I added a link to the documentation, which is quite clear too.  

---

