Question related to regression and interpolation

45 Views Asked by At

Suppose I have a non linear function between two variables $x(t)$ and $y(t)$ where $x$ and $y$ are both functions of some variable $t$. Now, i am primarily interested in the ratio of ${\frac {dx}{dt}}$ and ${\frac {dy}{dt}}$ which I want to approximate using a single constant. One way to do this is to approximate the non linear function between x and y with a straight line using linear regression(i only have a limited number of values for x(t) and y(t) for a set of t values) to get an equation like $y = mx+c$ where the slope $m$ of this line will be the constant that i want (ratio of ${\frac {dx}{dt}}$ and ${\frac {dy}{dt}}$). Instead of doing this, if I approximate the non linear function between x(t) and y(t) with a best fit polynomial using higher order terms of x and then i take the derivative of this polynomial and I approximate the derivative function using a constant function using some suitable method (like fitting a horizontal line through the derivative using maybe least squares regression) would there be any advantage as to the accuracy of the constant obtained using this method compared to the original linear regression? If not, is there a better way to approximate the ratio of ${\frac {dx}{dt}}$ and ${\frac {dy}{dt}}$?

1

There are 1 best solutions below

0
On

I suppose that your functions are defined by points that is to say that you have $m$ data points $(t_i,x_i)$ and $n$ data points $(t_j,y_j)$ where the $t_j$'s could totally differ from the $t_i$'s but they cover the same interval (if the functions were analytic, there will not be any problem.

What is suggest is to build interpolation functions to get $y=f(t)$ and $x=g(t)$. For the point $t_*$ at which you want to compute ${\frac {dy}{dx}}$, in the worst case compute it as $${\frac {dy}{dx}}=\frac{f(t_*+\epsilon)-f(t_*-\epsilon)} {g(t_*+\epsilon)-g(t_*-\epsilon)}$$

For illustration, for the range $-1\leq t \leq 1$, I generated the $x_i=e^{t_i}$ using a stepsize equal to $\frac 18$ and the $y_i=\sin(t_i)$ using a stepsize equal to $\frac 1{10}$ built the interpolation functions.

Computing at $t=0.3$ $(\epsilon=0.001)$, this gave as an approximation $\frac {dy}{dx}=0.677039$ while the exact solution is $0.677091$.

For sure, if you need the computation to be done at a specific value of $x$, you will need to invert function $g(t)$ to get $t_*$.