Piecewise linear interpolation with uncertainties

In summary, you can't do piecewise linear interpolation if both the dependent and independent variables have uncertainties associated to them. You may be able to approximate a nonlinear function with data that follows a piecewise linear pattern, but it's not an easy task.
  • #1
Malamala
313
27
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
  • #2
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?
 
  • #3
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?
 
  • #4
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:
  • #5
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.
 
  • #6
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.
 
  • Like
Likes pbuk

FAQ: Piecewise linear interpolation with uncertainties

What is piecewise linear interpolation with uncertainties?

Piecewise linear interpolation with uncertainties is a method used to estimate the value of a function at a specific point within a given range, when only a limited number of data points are available. It involves dividing the range into smaller segments and approximating the function as a straight line within each segment.

How is piecewise linear interpolation with uncertainties different from other interpolation methods?

Piecewise linear interpolation with uncertainties differs from other interpolation methods in that it takes into account the uncertainties associated with the data points. This allows for a more accurate estimation of the function value at a given point, as it considers the potential errors in the data.

What are the benefits of using piecewise linear interpolation with uncertainties?

One of the main benefits of using piecewise linear interpolation with uncertainties is its ability to provide a more accurate estimation of a function value at a specific point, even with limited data. It also allows for the incorporation of uncertainties, which can improve the overall accuracy of the interpolation.

What are the limitations of piecewise linear interpolation with uncertainties?

One limitation of piecewise linear interpolation with uncertainties is that it assumes a linear relationship between the data points, which may not always be the case. It also requires a sufficient number of data points in order to accurately estimate the function value at a given point.

In what situations is piecewise linear interpolation with uncertainties commonly used?

Piecewise linear interpolation with uncertainties is commonly used in situations where there is a limited amount of data available and a more accurate estimation of a function value is needed. It is also often used in scientific and engineering applications, where uncertainties in data are common.

Similar threads

Replies
30
Views
3K
Replies
5
Views
2K
Replies
6
Views
2K
Replies
28
Views
2K
Replies
22
Views
3K
Replies
5
Views
1K
Back
Top