0
$\begingroup$

I know things about linear/quadratic fittings etc. I'm just wondering, if i know a set of data for value e.g. z=[-2.563 -0.1932 -0.1502 -0.1102 -0.836 -0.5234] and l=[1 2 3 4 5 6] m=[6 5 4 3 2 1] I want to write out a function of z in terms of l and m. How would i be able to start this? Many thanks in advance!

  • 0
    How is this recreational mathematics?2012-09-12
  • 0
    @joriki. I fixed it2012-09-12
  • 0
    It's not statistics, either -- I've replaced the tag by [tag:interpolation].2012-09-12
  • 0
    sorry, i don't know how that tag was made.2012-09-12
  • 0
    PooyaM made it; see above.2012-09-12

1 Answers 1

0

The values of $(l,m)$ all lie on one line, so this isn't actually a two-dimensional problem; you can just do a one-dimensional fit with respect to either $l$ or $m$. Then if you want to evaluate the function at an arbitrary point $(l,m)$, just project it onto the line $l+m=7$ and evaluate the fitted function there.

[Edit in response to comment:]

You only have function values on a single line. The best you can do if you want to approximate a function value off the line is to take the function value at the closest point on the line, which is the orthogonal projection of the point onto the line. The orthogonal projection of the point $(l,m)$ onto the line $l+m=7$ is $((7+l-m)/2,(7+m-l)/2)$, so you get the approximation by evaluating a function fitted with respect to $l$ at $(7+l-m)/2$ or evaluating a function fitted with respect to $m$ at $(7+m-l)/2$.

  • 0
    could you please explain more about projection part? I don't quite get that.2012-09-12
  • 0
    my situation is as follows, I have a matrix of z values depending on the l and m value, l always starts from 1 to some number n while m goes from n till 1. for example, with l= 1 2 3 4 5 ,m=5 4 3 2 1 and this z value will be a length of 5 vector which is totally different as the case with l=1 2 3 4 5 6 7 and m=7 6 5 4 3 2 1. So i couldn't really just use either l or m as the dependent variable to form the function of z. In that case, i wouldn't use that function to find z for all cases. Thank you anyway!2012-09-12
  • 0
    How do you mean, you couldn't really use either $l$ or $m$ as the dependent variable? What keeps you from doing it?2012-09-12
  • 0
    if i use l as dependent variable in first case, when l is 1, it gives a z value according to the function which is true as my original value of z. However, we can't use that l=1 to find z for another case. Unless, i have z in terms of l and m the same time.2012-09-12
  • 0
    are you saying i find a fit of z in terms of 7+m-l/2?2012-09-12
  • 0
    In case you mean $(7+m-l)/2$, yes, you could put it that way.2012-09-12
  • 0
    So i should put 7 as another dependent variable as the m+l changes for finding different set of z. Thank you!2012-09-12
  • 0
    @chenwan: I don't know what you mean by putting $7$ (a constant) as another dependent variable. It sounds like the opposite of what I meant. What I was trying to say is that you can reduce the problem by considering the function only on the line $l+m=7$ and regarding it there as a function of a single variable ($l$, $m$, $(7+m-l)/2$ or whatever other linear combination of $l$ and $m$ you prefer), not introduce yet another variable.2012-09-12
  • 0
    If you want to make this more explicit, you might as well say that you consider the function as a function of $l-m$; no need to add $7$ or divide by $2$, since this can be absorbed into the interpolating function.2012-09-12
  • 0
    Let me explain this more, i have results for z=[] with when x=[],y=[] which are equal length vectors. And i want to find z as a function of x and y , if i use x as the independent variable, e.g. x=[1 2 3 4 5], y=[5 4 3 2 1],z=exp(x). However, there is the problem, i have not only just one vector of z but z set up as the matrix value. in another case where x=[1 2 3 4 5 6] but with y=[6 5 4 3 2 1]. If we use the same function we defined before z=exp(x), we wouldn't be the same value for z in this case. That's the key problem here.2012-09-12
  • 0
    @chenwan: What do you mean by "$z$ set zp as the matrix value"? And why would you want to use the same function for a different set of data? Are the data sets somehow related? Please try to give a systematic presentation of the problem all in one piece; this is an inefficient way of discussing it.2012-09-12
  • 0
    z as a matrix form i mean for each x,y vector, there is different corresponding z vector. For simplicity. if x=[1 2 3],y=[3 2 1], z=[a b c]. while another case is x=[1 2 3 4] , y=[ 4 3 2 1], and z=[ d e f g]. Note these two z are totally different. But i need to combine those to find a suitable function for z in terms of x, y . So it must depending on both x and y value.2012-09-12
  • 0
    @chenwan: It's not clear to me what you mean when you say on the one hand that "these two $z$ are totally different" and on the other hand that you "need to combine those to find a suitable function for $z$ in terms of $x,y$". Are you saying that you want a single function $z(x,y)$ that interpolates *all* these function values, both the ones for $x=[1 2 3]$, $y=[3 2 1]$ and the ones for $x=[1 2 3 4]$, $y=[4 3 2 1]$? If so, why didn't you say that in the original question? In that case, you should fix the question to reflect what you actually intended to ask about.2012-09-12