Piecewise linear interpolation with uncertainties

Click For Summary
SUMMARY

This discussion focuses on performing piecewise linear interpolation with uncertainties in both independent variables (x1, x2) and the dependent variable (y). The challenge arises when multiple (x1, x2) pairs yield the same y value, complicating the interpolation process. The conversation highlights the importance of defining "knots," which are critical transition points in the piecewise function, and emphasizes that the problem becomes significantly more complex when the number and location of knots are unknown. Participants suggest that if specific knot locations are known, optimization can simplify the process, but uncertainty in knot placement necessitates a more sophisticated approach, potentially involving linear regression techniques.

PREREQUISITES
  • Understanding of piecewise linear functions
  • Familiarity with optimization techniques for curve fitting
  • Knowledge of linear regression concepts
  • Basic grasp of uncertainties in measurements
NEXT STEPS
  • Research optimization algorithms for determining knot locations in piecewise functions
  • Explore linear regression methods for multidimensional data
  • Learn about uncertainty propagation in mathematical modeling
  • Investigate existing libraries or packages for piecewise linear interpolation with uncertainties
USEFUL FOR

Data scientists, statisticians, and researchers involved in mathematical modeling, particularly those dealing with multidimensional data and uncertainties in measurements.

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.
 
  • Like
Likes   Reactions: pbuk

Similar threads

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