Questions tagged [interpolation]

Anything related to function interpolation, i.e. the mathematical techniques for estimating the (unknown) value of a function in a point on the basis of a set of known values in other (usually nearby) points. For interpolation of strings, see the [string-interpolation] tag.

Anything related to function interpolation, i.e. the mathematical techniques for estimating the (unknown) value of a function in a point on the basis of a set of known values in other (usually nearby) points.

See Wikipedia on interpolation.

In scientific software for statistical computing and graphics, function approx implements linear interpolation and function spline implements cubic spline interpolation.

For interpolation of strings, see .

5155 questions
148
votes
19 answers

Generate colors between red and green for a power meter?

I'm writing a Java game and I want to implement a power meter for how hard you are going to shoot something. I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0…
mmcdole
  • 91,488
  • 60
  • 186
  • 222
123
votes
2 answers

How can I get the output of a matplotlib plot as an SVG?

I need to take the output of a matplotlib plot and turn it into an SVG path that I can use on a laser cutter. import matplotlib.pyplot as plt import numpy as np x = np.arange(0,100,0.00001) y = x*np.sin(2*pi*x) plt.plot(y) plt.show() For example,…
user391339
  • 8,355
  • 13
  • 58
  • 71
122
votes
1 answer

How can I perform two-dimensional interpolation using scipy?

This Q&A is intended as a canonical(-ish) concerning two-dimensional (and multi-dimensional) interpolation using scipy. There are often questions concerning the basic syntax of various multidimensional interpolation methods, I hope to set these…
116
votes
10 answers

Math - mapping numbers

How do I map numbers, linearly, between a and b to go between c and d. That is, I want numbers between 2 and 6 to map to numbers between 10 and 20... but I need the generalized case. My brain is fried.
Sam
  • 6,167
  • 6
  • 26
  • 24
87
votes
7 answers

Html5 canvas drawImage: how to apply antialiasing

Please have a look at the following example: http://jsfiddle.net/MLGr4/47/ var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); img = new Image(); img.onload = function(){ canvas.width = 400; canvas.height =…
Dundar
  • 1,311
  • 1
  • 14
  • 25
76
votes
13 answers

Interpolate NaN values in a numpy array

Is there a quick way of replacing all NaN values in a numpy array with (say) the linearly interpolated values? For example, [1 1 1 nan nan 2 2 nan 0] would be converted into [1 1 1 1.3 1.6 2 2 1 0]
Petter
  • 37,121
  • 7
  • 47
  • 62
72
votes
11 answers

Android How to draw a smooth line following your finger

http://marakana.com/tutorials/android/2d-graphics-example.html I am using this example below. But when I move my fingers too fast across the screen the line turns to individual dots. I am not sure whether I can speed up the drawing. Or I should…
Somk
  • 11,869
  • 32
  • 97
  • 143
59
votes
4 answers

Which kind of interpolation best for resizing image?

I have a numpy array that I wish to resize using opencv. Its values range from 0 to 255. If I opt to use cv2.INTER_CUBIC, I may get values outside this range. This is undesirable, since the resized array is supposed to still represent an image. One…
Roee E
  • 753
  • 1
  • 6
  • 7
55
votes
5 answers

AngularJS strategy to prevent flash-of-unstyled-content for a class

I have an AngularJS project, I want to prevent a FOUC during page load on a classname. I've read about ng-template but that seems useful only for content within a tag. I would like it to be "login" on page load. Any…
Casey Flynn
  • 13,654
  • 23
  • 103
  • 194
54
votes
7 answers

Floating point linear interpolation

To do a linear interpolation between two variables a and b given a fraction f, I'm currently using this code: float lerp(float a, float b, float f) { return (a * (1.0 - f)) + (b * f); } I think there's probably a more efficient way of doing…
Thomas O
  • 6,026
  • 12
  • 42
  • 60
49
votes
3 answers

Inverse Distance Weighted (IDW) Interpolation with Python

The Question: What is the best way to calculate inverse distance weighted (IDW) interpolation in Python, for point locations? Some Background: Currently I'm using RPy2 to interface with R and its gstat module. Unfortunately, the gstat module…
Michael Allan Jackson
  • 4,217
  • 3
  • 35
  • 45
47
votes
4 answers

AngularJS multiple expressions concatenating in interpolation with a URL

I know this is long, but please bear with me. The problem is easy to understand, just takes some writing to fully explain it. Right now I'm getting this error Error: [$interpolate:noconcat] Error while interpolating: Strict Contextual Escaping…
user2669464
  • 969
  • 3
  • 12
  • 17
45
votes
7 answers

Property binding vs attribute interpolation

I have read an article about difference between property and attribute bindings. From what I understood, most of the time, Angular2 prefers property bindings, because after each change in data, the DOM would be updated. (If I am mistaken, please…
Maryam Gharibi
  • 531
  • 1
  • 5
  • 13
44
votes
7 answers

How to implement linear interpolation?

Say I am given data as follows: x = [1, 2.5, 3.4, 5.8, 6] y = [2, 4, 5.8, 4.3, 4] I want to design a function that will interpolate linearly between 1 and 2.5, 2.5 to 3.4, and so on using Python. I have tried looking through this Python tutorial,…
Helpless
  • 467
  • 1
  • 4
  • 4
43
votes
1 answer

Fish shell - How to interpolate a subcommand?

In bash I can say: $ echo "a$(echo b)c" abc How do I do this in the fish shell?
Joshua Cheek
  • 30,436
  • 16
  • 74
  • 83
1
2 3
99 100