Questions tagged [linear-interpolation]

Linear interpolation is the process of approximating intermediate values given an assumption that the ranges of missing data look roughly like straight lines.

Linear interpolation is largely used for its simplicity and is typically more effective given a greater density of data. The more complex the underlying relationship of the quantities involved, the less likely linear interpolation is to provide a good value estimates.

In scientific software for statistical computing and graphics, function approx performs 1D linear interpolation.

437 questions
11
votes
3 answers

Linear Interpolation using numpy.interp

I have a 1 dimensional array A of floats that is mostly good but a few of the values are missing. Missing data is replace with nan(not a number). I have to replace the missing values in the array by linear interpolation from the nearby good values.…
user1789657
10
votes
9 answers

C implementation of Matlab interp1 function (linear interpolation)

Do you know any C implementation of the Matlab interp1 function (just 'linear' one)? I know one for Java.
Luis Andrés García
  • 5,852
  • 10
  • 43
  • 57
10
votes
1 answer

How to interpolate points between two irregular sets of data?

I'm sorry for the somewhat confusing title, but I wasn't sure how to sum this up any clearer. I have two sets of X,Y data, each set corresponding to a general overall value. They are fairly densely sampled from the raw data. What I'm looking for is…
nucleon
  • 861
  • 6
  • 22
8
votes
4 answers

SQL Server view: how to add missing rows using interpolation

Running into a problem. I have a table defined to hold the values of the daily treasury yield curve. It's a pretty simple table used for historical lookup of values. There are notibly some gaps in the table on year 4, 6, 8, 9, 11-19 and 21-29. The…
Christopher Klein
  • 2,773
  • 4
  • 39
  • 61
8
votes
3 answers

Trilinear interpolation

So I'm trying to write a trilinear interpolation function but am having some trouble coming up with it. So first we have a 1D interpolation: float interpolate1D(float v1, float v2, float x){ return v1*(1-x) + v2*x; } And then 2D…
user1855952
  • 1,515
  • 5
  • 26
  • 55
7
votes
2 answers

Interpolation of irregular time series with R

Searching for linear interpolation of time series data in R, I often found recommendations to use na.approx() from the zoo package. However, with irregular timeseries I experienced problems, because interpolated values are distributed evenly across…
7
votes
1 answer

passing a tuple to fill_value in scipy.interpolate.interp1d results in ValueError

The docs in scipy.interpolate.interp1d (v0.17.0) say the following for the optional fill_value argument: fill_value : ... If a two-element tuple, then the first element is used as a fill value for x_new < x[0] and the second element is used for…
jmborr
  • 1,215
  • 2
  • 13
  • 23
7
votes
2 answers

R: Interpolation of NAs by group

I would like to perform a linear interpolation in a variable of a data frame which takes into account the: 1) time difference between the two points, 2) the moment when the data was taken and 3) the individual taken for measure the variable. For…
Ruben
  • 493
  • 4
  • 18
7
votes
3 answers

Interpolation of time series data with specific output time

I have database with time data. I want to interpolate the data to mach e specific time step. Id Time humid humtemp prtemp press t 1 2012-01-21 18:41:50 47.7 14.12 13.870 1005.70 -0.05277778 1 2012-01-21…
Marco Giuliani
  • 241
  • 2
  • 9
6
votes
1 answer

What are the differences between the two lerp functions?

In Floating point linear interpolation one user proposed this implementation of lerp: float lerp(float a, float b, float f) { return (a * (1.0 - f)) + (b * f); } While another user proposed this implementation of a lerp: float lerp(float a,…
tempdev nova
  • 211
  • 1
  • 8
6
votes
2 answers

Moving object from vector A to B in 2d environment with in increments of percents

I know coordinates of vectors A and B. How can I count first point between these two vectors? First vector X is 1% of the distance between vectors A and B. So first I will move object in vector A 1% closer to vector B. So I need to calculate vector…
newbie
  • 24,286
  • 80
  • 201
  • 301
6
votes
1 answer

Numpy percentiles with linear interpolation - wrong value?

The linear interpolation formula for percentiles is: linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j. Suppose I have this list with 16 observations: test = [0, 1, 5, 5, 5, 6, 6, 7, 7, 8, 11,…
jerbear
  • 361
  • 5
  • 14
6
votes
2 answers

What algorithm does GL_LINEAR use exactly?

The refpages say "Returns the weighted average of the four texture elements that are closest to the specified texture coordinates." How exactly are they weighted? And what about 3D textures, does it still only use 4 texels for interpolation or more?
Wingblade
  • 9,585
  • 10
  • 35
  • 48
6
votes
2 answers

Calculate quantiles in R without interpolation - round up or down to actual value

It's my understanding that when calculating quantiles in R, the entire dataset is scanned and the value for each quantile is determined. If you ask for .8, for example it will give you a value that would occur at that quantile. Even if no such…
jsuprr
  • 97
  • 1
  • 6
6
votes
1 answer

lerp implementation for a "tween"

I have this as my lerp function: Vec2f lerp(float t, Vec2f a, Vec2f b){ return (1-t)*a + t*b; } And I have the following code below, which I was hoping that would result in a "tween": Vec2f a(0,0); Vec2f b(3,4); Vec2f c(5,4); …
crispyfriedchicken
  • 249
  • 3
  • 5
  • 16
1
2
3
29 30