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
4
votes
4 answers

Fill NA's at boundary of a vector in r

I have a vector containing NA's at the boundary x <- c(NA, -1, 1,-1, 1, NA, -1, 2, NA, NA) I want the outcome to be: c(-3, -1, 1,-1, 1, 0, -1, 2, 5, 8) In other words, I want to fill both inner and boundary NA's with linear interpolation (maybe I…
Hongfei Li
  • 59
  • 6
4
votes
1 answer

Interpolate values in one column of a dataframe (python)

I have a dataframe with three columns (timestamp, temperature and waterlevel). What I want to do is to replace all NaN values in the waterlevel column with interpolated values. For example: The waterlevel value is always decreasing till it is 0.…
user7335295
  • 401
  • 2
  • 7
  • 31
4
votes
1 answer

How do I linearly interpolate (lerp) ranged input to ranged output?

I want to generically interpolate between a range of input values (say, between A and B) and get a range of output values (say, between C and D). Sometimes I want to clamp the value (so that B+10000 still outputs D) and sometimes I don't. How do I…
Phrogz
  • 296,393
  • 112
  • 651
  • 745
4
votes
5 answers

RGB 24 to 16-bit color conversion - Colors are darkening

I noticed that my routine to convert between RGB888 24-bit to 16-bit RGB565 resulted in darkening of the colors progressively each time a conversion took place... The formula uses linear interpolation like so... typedef struct _RGB24 RGB24; struct…
oldSkool
  • 1,212
  • 5
  • 14
  • 29
4
votes
0 answers

scipy.interpolate.Rbf Memory error

I am running this code: F = interpolate.Rbf(X,Y,Z,V, function = 'linear') Where X,Y,Z and V shapes are: (1300, 691, 122) (1300, 691, 122) (1300, 691, 122) (1300, 691, 122) and i am getting this error every time i run my script. Traceback (most…
Christos ZS
  • 109
  • 2
  • 11
4
votes
1 answer

Multiple 1d interpolations in python

I am working on simulating traps in CCD arrays. Currently I am using NumPy and Scipy, and I have been able to vectorize most of the calls which have given me some speed-up. At the moment the bottleneck in my code is that I have to retrieve a number…
Skottfelt
  • 86
  • 8
4
votes
2 answers

Linear interpolation (lm) in R, weird behavior

Using R 3.2.2, I found a weird behavior running a simple linear interpolation. The first data frame gives the right result : test<-data.frame(dt=c(36996616, 36996620, 36996623, 36996626), value=c(1,2,3,4)) lm(value~dt, test)$coefficients …
Yves
  • 43
  • 2
4
votes
1 answer

Speeding up an interpolation exercise

I'm running about 45,000 local linear regressions (essentially) on about 1.2 million observations, so I'd appreciate some help trying to speed things up because I'm impatient. I'm basically trying to construct year-by-position wage contracts--the…
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
4
votes
1 answer

Is there any multivariate version of the function interp1 in R?

I am looking for a way to compute the linear interpolation of a multivariate function (of 5 variables) using R. The package akima offer a way to compute the linear interpolation in the bivariate case. Is possible to perform the multivariate linear…
4
votes
1 answer

Incorrect linear interpolation with large x values using Math.Net Numerics

I'm trying to use Math.NET Numerics to do interpolation of a DateTime - Value series. I started off with linear interpolation, but am getting some very off looking results. Running this test: public class script{ public void check_numerics() { …
jdpilgrim
  • 358
  • 3
  • 13
4
votes
3 answers

Performing constant interpolation in R

I have a set of data, for example: x<-c(1, 2, 3, 4, 5, 6) y<-c(100, 110, 121, 133.1, NA, 161.051) Now, y is clearly increasing at a constant rate of 10%. I want to be able to interpolate the data at x=5, and I want to print 146.41 as the answer.…
Randomly Named User
  • 1,889
  • 7
  • 27
  • 47
4
votes
2 answers

what kind of algorithm for generating height-map from contour line?

I'm looking for interpolating some contour lines to generating a 3D view. The contours are not stored in a picture, coordinates of each point of the contour are simply stored in a std::vector. for convex contours : , it seems (I didn't check by…
4
votes
0 answers

interpolation of grouped data using data.table

This is a continuation of a question that I had originally posted at http://r.789695.n4.nabble.com/subset-between-data-table-list-and-single-data-table-object-tp4673202.html . Matthew had suggested that I post my question here so I am doing that…
iembry
  • 962
  • 1
  • 7
  • 23
3
votes
1 answer

How do I make an Infinite marquee with JS?

I'm trying to make an Infinite marquee that speeds up on scroll, https://altsdigital.com/ you can see the effect on this website, the text says "Not your usual SEO agency" and when you scroll it speeds up. Here's what I've tried but it does not…
awawawaw
  • 175
  • 3
  • 11
3
votes
0 answers

How do I repeatedly interpolate linearly between two values within a requestAnimationFrame loop

I'm trying to implement multiplayer position interpolation for my canvas game but I'm having trouble using my linear interpolation (lerp) function. I experience slight jitter when using t = 0.1 so I'm looking for some alternative way to calculate t…