Reputation: 373
I'm trying to interpolate a quantile function (inverse CDF) from a set of x (quantiles) and y (values) samples, using several methods from scipy. Since it is a quantile function, the values sometimes repeat themselves. For example, the CDF eventually flattens out at 1, so x=1 repeats for several increasing y values:
x = [0, 0.19026078648166053, 0.5364188373245662, 0.9627927389184123, 0.9997059472175255, 0.9997059472175255, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999]
y = [0, 468, 1171, 4918, 10072, 20066, 29982, 45207, 59964]
It seems that some interpolation methods are built for functions, and aren't happy with repeating x's. Some even assume that repeating x's are derivatives (e.g. Krogh).
Any idea how can I get around this?
Upvotes: 3
Views: 2389
Reputation: 19
I just faced the same problem (I have a curve with repeating x values and want to interpolate it to get same arc length between the datapoints in x-y plane), and came to the following solution which works for me: Think of your x-y function as of a parametric function with x(t) and y(t), where t is some increasing parameter (simply the index of x or y arrays, or arc length). Then you can proceed with making interpolation of x(t) and y(t) separately. This way you cannot access directly y(x), but you can scan through the t values to get a combination of interpolated x and y values you are looking for. The same probably can be done also in some kind of 2D interpolation.
Upvotes: 1