...

/

Linear Interpolation

Linear Interpolation

Learn how to apply linear interpolation to missing data in SQL.

Overview

So far, we've seen how to fill in missing data using constant values or using a next or a last known value. These approaches are fairly simple, but they are a bit crude. There are other interpolation methods that fill in missing values in a more natural way.

Linear interpolation formula

Using linear interpolation filling missing values along a linear line between two known coordinates , we fill in missing values along a linear line between two known coordinates–-the last known value and the next known value.

This the formula to calculate linear interpolation:

y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0))
Linear regression formula

The formula uses the following:

  • (x0, yo) , (x1, y1): The ...

Access this course and 1400+ top-rated courses and projects.