2
votes

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?

1
In your specific case where one end of the chart starts diverging in terms of angle, I have done this in the past: Take the points with same x-value (all 1), say we have N of those, then span a range of values (linspace, e.g.) from 0.999 to 1.001 with N points (say) and assign a unique x-value to each of the N points (so y increases). To the eye, and practically, it's the same, but the interpolator now works. Depending on your application this has done the job for me before. In other cases where same-x-values are due to noise obviously a sort of smoother would be good to apply first, etc.denvar

1 Answers

2
votes

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.