[SciPy-User] inverse function of a spline

Charles R Harris charlesr.harris at gmail.com
Fri May 7 13:57:04 EDT 2010


On Fri, May 7, 2010 at 10:40 AM, <josef.pktd at gmail.com> wrote:

> I have a function  y = f(x) which is monotonically increasing (a
> cumulative distribution function)
> f is defined by piecewise polynomial interpolation, an interpolating
> spline on some points
>
> I would like to get the inverse function (ppf)  x = f^{-1} (y)
> if the spline is of higher order than linear
>
> In the linear case it's trivial, because the inverse function is also
> just a piecewise linear interpolation.
>
> If I have a cubic spline, or any other smooth interpolator in scipy,
> is there a way to get the
> inverse function directly?
>
> I don't know much about general properties of splines, and would
> appreciate any hints,
> so I can avoid numerical inversion (fsolve or similar)
>
>
Since the curve is piecewise cubic the problem reduces to inverting a piece
of a cubic, which inverse won't itself be a cubic in general. I think your
best bet is interpolate the same points with x,y reversed, or resample using
your spline and interpolate the new samples with x,y reversed. It won't be a
exact inverse, but then, the original is probably not exact either.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20100507/26b2726b/attachment.html>


More information about the SciPy-User mailing list