# 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: $$\begin{equation}\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 \end{equation}$$

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: $$\begin{equation}\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 ) \end{equation}$$

Covariance $$\textbf{C}$$ of parameters $$\textbf{S}$$ is than calculated as: $$\begin{equation}\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} \end{equation}$$ $$\begin{equation}\label{eq:covariance} \textbf{C} = \alpha^{-1} \end{equation}$$

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:

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

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

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!