# Linear Interpolation with few data points

Have another question:

I want to replicate =FORECAST() formula from Excel which does linear interpolation.

Here is my example:

Column X Column Y
X= 1; Y=3
X=1.4; Y=?
X=2 ; Y=4

Y value for 1.4 should be 3.4. If I use Missing Value Note and select Linear Interpolation it retrieves 3.5 which is a simple average of available values in column Y and it does not take into account values in column X. Is there a way to obtain 3.4 value? Linear Regression Predictor does not work here.

Thank you

Hi,
Indeed the Linear Regression Learner seems to have problems with such few datapoints. If you really only have 2 known rows, you can easily calculate it yourself, though.
If in your example `x1 = 1, y1 = 3, x2 = 2, y2 = 4, x = 1.4, and y = ?` you can derive a formula for y:

``````(x2 - x1) / (y2 - y1) = (x - x1) / (y - y1)   | bring y to one side
(x - x1) * (y2 - y1) / (x2 - x1) + y1 = y
``````

This formula you can use to calculate y for arbitrary x. What you need to do for that, though, is to Unpivot the table, then transpose it, then turn the values into flow variables. Then you can use a Math Formula node for the interpolation. The workflow for it is a bit longer than I would have liked, but pretty straight-forward. Please have a look here. Let me know if you have any questions!
Kind regards,
Alexander

3 Likes

That is exactly it. Thank you Alexander

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.