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
2
votes
1 answer

Maintaining point correlation while flattening 2D meshgrid

How can I flatten three separate two dimensional arrays, while maintaining point correlation? For example, I am creating a meshgrid from a dataset containing position information for x and y, and some correlated data array (cartm). After the…
AaronJPung
  • 1,105
  • 1
  • 19
  • 35
2
votes
1 answer

scipy.interp2d warning and different result than expected

I'm trying to convert MATLAB code to equivalent python. I have 3 arrays and I want to compute interp2d: nuA = np.asarray([2.439,2.5,2.6,2.7,2.8,3.0,3.2,3.5,4.0,5.0,6.0,8.0,10,15,25]) nuB = np.asarray([0,0.1,0.2,0.3,0.5,0.7,1]) a, b =…
shozdeh
  • 172
  • 1
  • 11
2
votes
1 answer

Linear interpolation with interp1d performance issues with large datasets python (scipy)

I have a large dataset (~300,000 data points) from which I sample about ~300,000 numbers. I first form an empirical CDF, and then use intrep1d to create an interpolation object for the inverse of CDF. Then I generate random numbers from a uniform…
sodiumnitrate
  • 2,899
  • 6
  • 30
  • 49
2
votes
3 answers

linear interpolation with grided data in python

I've a gridded weather data set which have a dimension 33 X 77 X 77. The first dimension is time and rest are Lat and Lon respectively. I need to interpolate (linear or nearest neighbour) the data to different points (lat&lon) for each time and…
pkv
  • 107
  • 1
  • 11
2
votes
1 answer

How to interpolate and extract points above loess smooth in R?

(This post is the second half of the problem from: How to apply loess.smoothing to both plot and then extract points?) I have plotted loess smoothing to a scatterplot (i.e. between two quantitative variables). I would like to extract only the data…
user1830307
2
votes
1 answer

Interpolation search out of range

This is a piece of Wikipedia's sample implementation of interpolation search: public int interpolationSearch(int[] sortedArray, int toFind){ // Returns index of toFind in sortedArray, or -1 if not found int low = 0; int high =…
2
votes
1 answer

Using linear interpolation to animate a line moving from point A to point B

struct Point{ float x; float y; }; Using this struct I made 4 points, and assigned them values. The instances of the Points are then used to create the lines shown in the picture. PO.x = -0.5f; PO.y = 0.5f; P1.x = -1.0f; P1.y =…
Moynul
  • 635
  • 1
  • 8
  • 30
2
votes
1 answer

How to get t for average distance of Bézier curve

I am calculating the interpolation position of Bézier curve by using the formula: pow(1 - t, 2) * start + 2.0 * (1 - t) * t * control + t * t * end The problem is that if I linear step the t by for example 0.1 per segment, the length of segment on…
kobunketsu
  • 157
  • 2
  • 10
2
votes
1 answer

How to calculate the slope of a point on a terrain data (e.g. Digital Elevation Matrix)

I want to implement a 3D car racing game and I need to approximate the magnitude and the direction of the slope of any arbitrary point on a terrain. Terrain Data Format: - heights[ ][ ]: 2D array of floats (representing heights in meters) - unit:…
Benji Mizrahi
  • 2,154
  • 2
  • 23
  • 38
2
votes
2 answers

python: numpy - calculate percentile with linear interpolation

I am trying to calculate percentile after reading the wikipedia I implemented the simple formula def _percentile(numList, percentile): numList.sort() n = int(round(percentile * len(numList) + 0.5)) if n > 1: return numList[n-2] …
add-semi-colons
  • 18,094
  • 55
  • 145
  • 232
2
votes
4 answers

Linear interpolation of three 3D points in 3D space

I have three 3D points like p1(x1,y1,z1), p2(x2,y2,z2), p3(x3,y3,z3). I have another point, but I know only x, y value of that point like p4(x4,y4,Z), in which Z is the value I like to compute. I am sure p4(x4,y4) point is inside a triangle formed…
batuman
  • 7,066
  • 26
  • 107
  • 229
2
votes
2 answers

How to build a lookup table for tri-linear interpolation in NumPy?

The following extract is of a 500 row table that I'm trying to build a numpy lookup function for. My problem is that the values are non-linear. The user enters a density, volume, and content. so the function will be: def capacity_lookup(density,…
dassouki
  • 6,286
  • 7
  • 51
  • 81
2
votes
2 answers

Interpolate between two modelview matrices

In OpenGL, given two camera positions (i.e. model view matrices), I would like to smoothly transition between them. That is, I want to interpolate between the two modelview matrices. I've seen many resources that talk about using SLERP to…
t2k32316
  • 993
  • 1
  • 13
  • 29
2
votes
1 answer

SciPy interp2d(linear) results are different than MatLab interp2(linear)

I'm converting a MatLab program to Python, and I'm having problems understanding why scipy.interpolate.interp2d(linear) is giving different results than MatLab interp2(linear). i know scipy.interpolate.rectbivariatespline is giving same result than…
z e
  • 21
  • 3
2
votes
0 answers

linear interpolation with interp2d or scipy.interpolate.RectBivariateSpline

I'm quite new to python and want to interpolate in a regular grid. First, i tried it with interp2d. This worked for most cases, however for some cases (the only difference were the values) there was a warning and the result was not as expected. This…
Mathias
  • 21
  • 1
  • 2