Least-square fitting to data (sine function) : what is the error of the derived fit parameters

analysisdata analysisleast squaresmathematical physicsmean square error

I have a set of data. I want to fit it to a sine function of the form :
\begin{equation}
f(x)=A sin(\omega x+B)+C
\end{equation}

I use the least-square method to find the appropriate fit-parameters which are $A$, $B$ and $C$. In this method, each term of the cost-function has a weight calculated from the error-bar of each point in my dataset.

Now I want to calculate the visibility $V$ for the fitting curve. The visibility is defined by :
\begin{equation}
V=\frac{A}{C}
\end{equation}

I obtain a good value of $V=0.95$, but now I want to know how to calculate $\Delta V$, the error of the visibility. To get it, I need to know $\Delta A$ and $\Delta C$.

Do you know how to do it ?

EDIT : Some people suggested to post the data, so here is the figure on the link below.
Figure representing the data

Basically, each point has a poissonnian error bar $\Delta Y= \sqrt{Y}$. I did the weighted least-square method to obtain my fit-function which is the solid line you can see on this plot (there is two data-set actually, red and blue). The area in red/blue represent standard deviation of the distance in errorbar unit from the datapoints to the fit, multiplied by the poissonian error $\sqrt{Y}$ [I don't know if this is okay, maybe it's false to do like that].

Best Answer

This fitting problem can be equivalently rewritten as fitting function of form:

$$ f(x) = K \sin(\omega x) + L \cos(\omega x) + C $$

And your original $A$ is just $A =\sqrt{K^2+L^2}$

This reduces it to just ordinary least squares problem. We get least squares estimators for $K,L$ from the equation

$$\begin{bmatrix} K \\ L \\ C \end{bmatrix} = (X^TX)^{-1}X^{T}y$$

Where $X$ is matrix formed by values of $\sin(\omega x),\cos(\omega x), 1$ evaluated at consecutive values of $x$ coordinate of your observations and $y$ are values of said observations.

This way you can see that $K,L$ are some linear functions of $y_i$. I'm not sure what Poissonian error bar is but in general finding variance of sum of variables can be done if we know variance of individual variables.

Assuming $y_i$ uncorrelated we get:

$$ {Var}(K) = (1,0,0) . (X^TX)^{-1}X^{T} . Var(y_i)$$

and analog for $L$.

And $C$ is even simpler as it is just the mean value of the observations.

This way we have found $Var(K),Var(L),Var(C)$ assuming these are small enough you can just propagate error in the formula

$$ V = \frac{\sqrt{K^2+L^2}}{C} $$

either by direct computation or using this helpful lookup.

Related Question