A Piecewise linear interpolation with uncertainties

Click For Summary
The discussion centers on performing piecewise linear interpolation with uncertainties in both dependent and independent variables. The challenge arises when multiple pairs of independent variables yield the same dependent variable, complicating standard interpolation methods. Choosing specific knot locations simplifies the problem to an optimization task, while unknown knots increase complexity significantly. The conversation highlights that the situation is further complicated by the two-dimensional nature of the data. Ultimately, the focus shifts from simple interpolation to the more complex task of linear regression, which may require specialized algorithms or packages for effective resolution.
Malamala
Messages
348
Reaction score
28
Hello! I have a function ##y = f(x_1,x_2)##, and I would like to do a piecewise linear interpolation. However, both the dependent (##y##) and independent variables (##x_1, x_2##) have uncertainties associated to them (the uncertainty is the same for a given variable i.e. all ##x_1## measurements will have the same uncertainty). How can I do piecewise linear interpolation in this case? I am mainly worried about cases where different ##(x_1, x_2)## will give the same ##y##, in which case normal piecewise linear interpolation would fail (or not?), but that is still physically correct, given that ##y## has some uncertainty. Is there an easy way to deal with uncertainties in this case? Thank you!
 
Physics news on Phys.org
If you have specific locations where you want to put the knots (where it transitions from one linear function to another) then it's just an optimization problem to find the best fit (plus maybe you want to apply some priors). If you don't know where the knots should go, or even worse how many you want, it becomes more complicated.

Which scenario are you in?
 
Office_Shredder said:
If you have specific locations where you want to put the knots (where it transitions from one linear function to another) then it's just an optimization problem to find the best fit (plus maybe you want to apply some priors). If you don't know where the knots should go, or even worse how many you want, it becomes more complicated.

Which scenario are you in?
What do you mean by knots?
 
Knots are your choice of x value where your piece wise function transitions between pieces - in your case, where you have a linear function in thy left, and one on the right, and they intersect at a certain x value.

Edit to add: for example if you knew you wanted to have a linear function in each of the four quadrants, then the problem would be greatly simplified
 
Last edited:
Office_Shredder said:
Knots are your choice of x value where your piece wise function transitions between pieces - in your case, where you have a linear function in thy left, and one on the right, and they intersect at a certain x value.

Edit to add: for example if you knew you wanted to have a linear function in each of the four quadrants, then the problem would be greatly simplified
In my case I can choose the ##(x_1,x_2)##, but I do have uncertainties on the values. Also the obtained value for the y can be the same for 2 different ##(x_1,x_2)## pairs. For example it might be that ##f(0,0) = f(0,0.1)## and I am not sure how to deal with that.
 
Sorry, I am not talking about the data, I'm talking about the best fit function.For example suppose you have y=|x| (function of one variable). This is a piecewise linear function with a knot at x=0.

If you have data of the form (x,y) and you want to fit a piecewise linear function, you could do something like say it has one knot at 0, and find the best combination of line before x=0 and line after x=0. This is an easy problem to solve. On the other hand you could say you know there is one knot, you just don't know where it is. This is also not hard to solve. What is really hard is if you say there are multiple knots of unknown number, and unknown location. If you don't actually believe your data is a piecewise linear function and are just trying to approximate a nonlinear function, this is probably the state you are in (from what you have posted so far I think this is probably what you're doing?)

Your situation is even harder, because the domain is 2 dimensions. An example of a piecewise linear function would be ##f(x_1,x_2)= |x_1| + |x_2| +|x_1+x_2 |## this has knots along the lines ##x_1=0##, ##x_2=0## and ##x_1+x_2=0##.

Picking where the knots go and how many of them there should be is a non trivial question that doesn't have a literal answer - it's a balance between making a model with more predictive power vs one that is overfit. That's why if you come in knowing what they should look like, you can get a significantly better answer.

I think the real point here is you don't want to do linear interpolation, which is easy, but linear regression, which is a lot harder. I'm not immediately sure if there is a package/algorithm that will just solve this problem for you, but I feel like there should be one. I'll look around a little more for it.
 
There is a nice little variation of the problem. The host says, after you have chosen the door, that you can change your guess, but to sweeten the deal, he says you can choose the two other doors, if you wish. This proposition is a no brainer, however before you are quick enough to accept it, the host opens one of the two doors and it is empty. In this version you really want to change your pick, but at the same time ask yourself is the host impartial and does that change anything. The host...

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
4
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K