3
$\begingroup$

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].

$\endgroup$
4
  • $\begingroup$ Basically I need to know how to get the uncertainties on A and C (because $V=A/C$). I will edit my question. $\endgroup$ Jun 3, 2019 at 14:40
  • $\begingroup$ Would you mind post your example of data. Concret example is useful to evaluate the difficulty of your problem and well understand it. $\endgroup$
    – JJacquelin
    Jun 3, 2019 at 15:24
  • $\begingroup$ Yes I edited my question $\endgroup$ Jun 4, 2019 at 8:59
  • $\begingroup$ If this is not a school work, I suggest you use a professional tool. $\endgroup$
    – NoChance
    Jun 4, 2019 at 9:42

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
6
  • $\begingroup$ $X$ is called design matrix. Maybe that will help with the coding part. $\endgroup$
    – Radost
    Jun 4, 2019 at 9:55
  • $\begingroup$ That is exactly what I was looking for, thank you ! $\endgroup$ Jun 4, 2019 at 12:30
  • $\begingroup$ Your linear method is not convenient. You use an unknown value of $\omega$ to compute the matrix $X$. With this method one cannot compute the value of $\omega$. In fact the equation $ f(x) = K \sin(\omega x) + L \cos(\omega x) + C $ is not linear with respect to $\omega$. One have to use a more sophisticated method in case of non-linear equation. $\endgroup$
    – JJacquelin
    Jun 4, 2019 at 18:44
  • $\begingroup$ @JJacquelin OP literally said that only the amplitude was unknown implying that $\omega$ was known and fixed. If you want to fit $\omega$ it is a completely different problem. (Indeed a non-linear, and by some measure harder one). $\endgroup$
    – Radost
    Jun 4, 2019 at 19:09
  • $\begingroup$ From the picture uploaded looks like the domain of $x$ is $[0,2\pi)$ so $\omega$ is probably just $1$. $\endgroup$
    – Radost
    Jun 4, 2019 at 19:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .