Minimum required data for cosine fit

262 Views Asked by At

With a minimum amount of (noisy) data-points, I need to find the amplitude of a simple cosine $y=A*cos(x)$, where x is an angle from $0$:$2\pi$.

I know how to fit data to the function, and I know how to find the goodness of fit.

However, I receive my data over time, in random order. I want to minimize the 'gathering' time. Therefore, I am trying to define a bound that determines that I have received enough data to make a reasonable fit.

For example, I cannot simply set a bound on the number of data-points, as you could do for a linear function. This is because the data that corresponds to $x = 0.5\pi$, $x=1.5\pi$ are useless ($y(x) =0$), while data corresponding to $x=0$, $x=\pi$ are very useful ($y(x)=A$). Not just the amount of data matters, also its $x$-location.

What is a good metric that relates my data to how well the amplitude of a cosine can be found?

1

There are 1 best solutions below

6
On BEST ANSWER

I dont know how useful will be my answer. I assume here that your objective is to minimize the sum of squares of the absolute errors on $Y$'s. Then, I suppose that, for the optimum $A$ parameter, you use $A = S_1 / S_2$, in which $S_1$ is the sum of $y(i)\cos[x(i)]$ and $S_2$ is the sum of $\cos^2[x(i)]$; the summations run from $i=1$ to $i=N$.

If you acquire a new data point, you just need to add $y(N+1)\cos[x(N+1)]$ to $S_1$ to update this quantity and to add $\cos^2[x(N+1)]$ to $S_2$ to update this other quantity. So, very few operations are required every time you add one data point.

Since this procedure is very inexpensive, I should not worry about the number of points and I should not discard any data point since, at the same time, each point is in error and brings information.