# Covariance generated from best-fit chi error function

I came across definition of covariance matrix that is defined from best fit error equation. I would like to clarify correctnes of procedure.

We define equation for error: $$$$\label{eq:fitgood} \chi^2 = \sum _{\text{i=0}}^\text{N} \frac{1}{\sigma_\text{i}^2}( I_\text{i}-I_\text{D}(\theta_\text{i}, \textbf{S}) )^2$$$$

where: $$I_\text{i}$$ is measured signal and $$I_\text{D}$$ predicted signal. $$\sigma_\text{i}^2$$ is variance of measured signal. It is calculated from repeated measurements.

Model is defined as: $$$$\label{eq:enacbafurr} I_\text{D}(\theta_\text{i}, \textbf{S}) = \frac{1}{2}( S_0 - S_1 \,\text{cos}^22\theta_i - S_2 \, \text{sin}2\theta_i \text{cos}2\theta_i + S_3 \, \text{sin}2\theta_i )$$$$

Covariance $$\textbf{C}$$ of parameters $$\textbf{S}$$ is than calculated as: $$$$\label{eq:curvaturmtx} \alpha_\text{k,l} = \frac{1}{2} \bigg( \frac{\partial \chi^2}{\partial S_\text{k} \partial S_\text{l}} \bigg)_\textbf{S}$$$$ $$$$\label{eq:covariance} \textbf{C} = \alpha^{-1}$$$$

I would like to know if there are limitations of using this procedure. I would be really pleased if someone can redirect me to some literature where this procedure is described. I would like to know why this is true and not just blindly follow the recipe.

Another thing. I know that from LSE method perspective covariance matrix could be calculated as:

$$$$\text{cov}{\textbf{(S)}} = \sigma^2(\textbf{X}^T\textbf{X})^{-1}$$$$

where: $$$$\sigma^2 = \frac{e^Te}{N-n}$$$$

but I was unable to calculate it this way. Can someone tell me the approach I should take to modify equations properly in the form of matrices. Thank you in advance!