2
$\begingroup$

I want to interpolate a function given 3 $x$ points ($0$, $0.5$ and $1$) and their correspondent $y$ values. $x$ values will be always between $0$ and $1$.

How can I interpolate a given value, like $0.3$? And what about if I add more sample data, can I improve the interpolation accuracy?

Example

This is the problem I'm trying to solve: in a football fantasy game each player has an associated price $y$. Each player value is calculated from a quality factor, $x$, a value from $0$ to $1$, where $0$ is a poor-performance player and $1$ is a top level player. Given that quality factor, the price would be calculated interpolating the value from this data:

| $x$ | $y$ |

| $0$ | lowest price in database |

| $0.5$ | average price in database |

| $1$ | highest price in database |

So, given $y(0)=10$, $y(0.5)=75$ and $y(1)=100$ we have this chart:

sample chart


I found this solution using WolframAlpha

$2. a x^2 - 3. a x + a - 4. b x^2 + 4. b x + 2. c x^2 - c x$

Where $a$ is low price, $b$ average price and $c$ expensive price.

  • 0
    A little bit more details and context would be nice. One could fill books with that question. If you have no idea where to start, Wikipedia is usually not a bad idea.2017-02-06
  • 0
    I've added more details to the question2017-02-06
  • 0
    It looks like Wolfram Alpha proceeded with **polynomial** Interpolation. But what do **you** want? There are many interpolation techniques. For example some preserves monotonicity of the data, some not (like non linear polynomial interpolation). You need some details about the function you want to interpolate. Is it smooth, is it monoton, is it convex, what ever. That also matters if you ask for minimizing error. Here again, what kind of error? Uniform? In average? Otherwise you could just connect the 3 points with a polygon (which is in fact not that bad).2017-02-06

1 Answers 1

1

For a low number of points, you can use polynomial interpolation as given by the Lagrange formula (https://en.wikipedia.org/wiki/Lagrange_polynomial). For three points, you get a quadratic expression, corresponding to a parabola.


Lagrange's formula works for any number of points, but quickly becomes unstable for larger $n$ (do not exceed, say, $n=10$). A better alternative is piecewise polynomial interpolation, such as cubic splines (https://en.wikipedia.org/wiki/Spline_interpolation).