Approximating on a line

185 Views Asked by At

Say I have sampled some points in $[0,1]^2$ and evaluate a function $f(x,y)$ for them. I am interested in the behavior of $f$ along a single dimension.

If the points were like $(x_1,y_1),(x_1,y_2),\ldots,(x_1,y_N)$, then they lie nicely on a straight line, such that I can compare $f(x_1,y_1),f(x_1,y_2),\ldots,f(x_1,y_N)$ to inspect the behavior along the $y$-dimension, since $x$ is fixed.

However, my points lie scattered, e.g. the red points in the figure. Is there a way to 'project' these points onto a straight line (the same fixed $x$-coordinate)?

In the figure the red points are the only points were I know $f(x,y)$. To inspect $f$ along the $y$-dimension, I want to inspect points along a fixed $x$-coordinate, in this case the black dashed line. Is there a way to 'project' the red points onto this black line, such that they become the black points?

enter image description here

I am familiar with interpolation methods, but I was wondering if there is a more mathematically motivated/exact method to do this. For example 'filter out' the $x$-contributions.

So far I have tried interpolating, but the results really depend on the method of interpolation. Furthermore I thought about weighting the contribution of each point, according to the distance between that point and the black line, but that hasn't been very fruitful either.

Any help/thoughts/ideas is very much appreciated :)

1

There are 1 best solutions below

26
On BEST ANSWER

You have a table $(x_i,y_i,f(x_i,y_i))_{i=1}^n$. And a fixed value of $x$, denoted below as $x^*$.

If the $y_i$'s are unique you don't have an interpolation, but a Taylor expansion or so, which is an extrapolation. If they are not unique and you have values around given\fixed $x^*$, i.e. from both sides, then you can have uni-variable interpolation for this value. However, this won't use information from different values of $y_i$ which may affect the quality of your comparison along $y$ dimention, i.e. $f(x^*,y_j)$.

You can try any of the following:

  1. Define $w_i = \frac{1}{\|(x^*,y_i)\|_2^q} $ for some $q>0$

    Then $$f(x^*,y) \approx \sum_{i=1}^n f(x_i,v_i) v_i$$ where $$v_i = w_i\left(\sum_{j=1}^n w_j \right)^{-1}$$

    This would be Shepard's Method, some modifications are available, see.

  2. The approach above can be generalized as a approximation by a radial basis functions, or its modifications, e.g. this link. Note also this link. You can find matlab implementation of such approach here.

  3. You can also consider splines if you like.

  4. The Least Squares Fit is also good option.


Now about choosing the best $x^*$

Note the quality of the approximation is vary for a different $x^*$ and for different methods the better result is obtained at different $x^*$.

A naive method would be to choose something between all known $x_i$'s, e.g. $$x^*=\mathop{\mathrm{argmin}}\limits_{x^*\in[x_1,x_n]} \|x^*-x\|,$$ where $x=(x_1,\dots,x_n)$ are known values from the table.

However what you really want is $x^*$ that minimize $$Error(x^*)=\|f(x,y)-\tilde f(x^*,y)\|$$ where $f(x,y) = (f(x_1,y_1),\dots,f(x_n,y_n))$ and $\tilde f$ is the approximant. Generally to speak, you need to know to approximate the error term of the method you use at given point.


I'm adding another possible definition of error measurement (based on Shepard-like methods) suggested by A.S. in comments. Whether they are equivalent or one should be preferred on another is a question atm. However, I guess it can be used as well. $$Error(f,\tilde f)=E\left(\sum_i \frac{||f(x_i,y_i)-f(x^*,Y)||}{||(x_i,y_i)-(x^*,Y)||}\right)$$