# Curve fitting and error propagation for non-independent quantities

I have measurement values $$y_\mu$$ at times $$t_\mu$$; the should follow a function $$y(t) = f_t \, \cos (\Omega_t\cdot t - \delta)$$ where $$f_t, \Omega_t$$ are slowly varying functions (currently I am testing with constant functions). I need to determine the frequency $$\Omega$$, so I select all pairs $$(y_\mu, y_{\mu-1})$$ with a sign change $$\text{sig} \, y_\mu \neq \text{sig} \, y_{\mu-1}$$ and calculate the approximate value for the zero $$T_m$$ using

$$dt_m = t_m - t_{m-1}$$ $$dy_m = y_m - y_{m-1}$$

$$dT_m = -\frac{dt_m}{dy_m}y_m - t_m \quad (1)$$

Note that the $$y_m$$ defining the zeros $$T_m$$ form a very small subset of the original data $$y_\mu$$.

In order to determine $$\Omega$$ I use a linear fit in $$n$$ based on the target function

$$T(n) = \left(n + \frac{1}{2} \right) \frac{\pi}{\Omega} + \delta t$$

(which I have to generalize once I allow for slowly varying functions $$f_t, \Omega_t$$)

Fitting is done using a mean squared approach. This works as expected.

The problem is to determine the error estimation for $$\Omega$$. In principle, this is supported by the numerical library I am using; however, I need to specify the error for each data point as input; in my case the measurement values are the $$y_m$$, but the input for the fit are the values $$T_m$$, therefore I have to specify $$\Delta T_m$$.

Usually, for error propagation I would use

$$\Delta^2 T = \sum_a \left(\frac{\partial T}{\partial q_a} \right)^2 \Delta^2 q_a \quad (2)$$

where the $$q_a$$ are independent quantities, and $$\Delta q_a$$ their respective errors.

In my case this mean that for each $$T_m$$ I have to use $$y_m, y_{m-1}$$ and their respective errors $$\Delta y_m, \Delta y_{m-1}$$ to calculate the zero $$T_m$$ and its error $$\Delta T_m$$. But the $$y_m, y_{m-1}$$ are of course not independent, so $$(2)$$ can't be correct.

The question is, what replaces $$(2)$$, i.e. how do I determine the errors $$\Delta T_m$$, based on $$(1)$$?

• Would Cross Validated be a better home for this question? Commented Oct 16, 2023 at 10:04
• Why? Isn't this physics? Think about the determination of the frequency for a driven pendulum with slowly varying driving force.
– TomS
Commented Oct 16, 2023 at 10:29
• As shown in the Wikipedia article on error propagation under “linear combinations,” in general you need to take into account the covariance matrix, which will account for cross correlations in your underlying variables. Your equation (2) is only valid when the variables are sufficiently independent. en.wikipedia.org/wiki/Propagation_of_uncertainty Commented Oct 16, 2023 at 11:42

Usually, for error propagation I would use

$$\Delta^2 T = \sum_a \left(\frac{\partial T}{\partial q_a} \right)^2 \Delta^2 q_a \quad (2)$$

where the $$q_a$$ are independent quantities, and $$\Delta q_a$$ their respective errors.

For two correlated variables the error propagation would be

$$\Delta^2 T = \left(\frac{\partial T}{\partial q_1} \right)^2 \Delta^2 q_1 + \left(\frac{\partial T}{\partial q_2} \right)^2 \Delta^2 q_2 + 2\left(\frac{\partial T}{\partial q_1}\frac{\partial T}{\partial q_2} \right) \Delta^2 q_{12} \quad (2.1)$$ where $$\Delta^2 q_{12}$$ is the covariance of quantities 1 and 2.

Extending it to more quantities is straightforward.

$$\Delta^2 T = \sum_a \sum_b \frac{\partial T}{\partial q_a} \frac{\partial T}{\partial q_b} \Delta^2 q_{ab} \quad (2.2)$$ where $$\Delta^2 q_{ab}$$ is the variance for $$a=b$$ and the covariance for $$a\ne b$$.

• Thanks a lot. Unfortunately I don’t see how to apply the usual definition for the covariance: I have single runs, each run creates the time series $t_\mu, y_\mu$ from which I select the subset $t_m, y_m$ which defines the zeros in $y$. I don‘t see how to define a reasonable mean for the selected values $y_m$.
– TomS
Commented Oct 16, 2023 at 14:49
• My best suggestion in cases like that is to do a monte carlo simulation of your data generation process. Make sure that the resulting data looks reasonably realistic. Then you can use your monte carlo simulation to generate as many runs as you like and get a decent estimate for the variances and covariances.
– Dale
Commented Oct 16, 2023 at 15:13
• My problem is that the target function is $y(t) = y_0 \, f_t \, \cos(\Omega_t (t-t_0))$ where $y_0, t_0$ are not really under control for a single single run. So for one run to be evaluated these two parameters need to be fitted. That works quite nice, but I don’t know their values upfront and can’t calculate any reasonable mean. What I can do is to simulate the errors $\Delta y$ for specific values $y$ and determine the error distribution for the derived variable $T$. Is that, what you mean? I already did that Monte Carlo simulation ;-)
– TomS
Commented Oct 16, 2023 at 15:28
• @TomS if you can generate a Monte Carlo simulation of your data generation process then how can you not be able to estimate the covariances? That doesn't make any sense to me.
– Dale
Commented Oct 16, 2023 at 15:32
• @TomS by the way, this isn't part of your question, but if it were my data I would not try to estimate $\Omega$ by the zero crossings. I would take the Fourier transform of the $y_i$ and estimate $\Omega$ from that. The location of the peak in the Fourier domain directly gives you $\Omega$ and the width of the peak gives you the uncertainty in $\Omega$.
– Dale
Commented Oct 16, 2023 at 15:39