A Piecewise linear interpolation with uncertainties

Malamala
Messages
342
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.
 
Namaste & G'day Postulate: A strongly-knit team wins on average over a less knit one Fundamentals: - Two teams face off with 4 players each - A polo team consists of players that each have assigned to them a measure of their ability (called a "Handicap" - 10 is highest, -2 lowest) I attempted to measure close-knitness of a team in terms of standard deviation (SD) of handicaps of the players. Failure: It turns out that, more often than, a team with a higher SD wins. In my language, that...
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...

Similar threads

Back
Top