[SciPy-User] Fitting Polynomial With Shape Restrictions
josef.pktd at gmail.com
josef.pktd at gmail.com
Sun May 7 16:36:46 EDT 2017
On Sun, May 7, 2017 at 3:34 PM, Evgeni Burovski <evgeny.burovskiy at gmail.com>
wrote:
> On Sun, May 7, 2017 at 10:12 PM, Jared Vacanti <jaredvacanti at gmail.com>
> wrote:
> > Are there other techniques of fitting splines (perhaps using
> scipy.optimize
> > ?) where I can impose boundary conditions myself, even outside of the
> > options provided in scipy.interpolate?
>
> FITPACK has some spline fitting with convexity constraints, but I
> don't think it's exposed to python:
>
> https://github.com/scipy/scipy/blob/master/scipy/
> interpolate/fitpack/concon.f
> https://github.com/scipy/scipy/blob/master/scipy/
> interpolate/fitpack/cocosp.f
>
> Hyman et al have some discussion of constructing local interpolants
> with convexity constraints:
> http://math.lanl.gov/~mac/papers/numerics/DEH89.pdf
> and references therein.
>
>
I looked into monotonicity and similar constraints for splines several
years ago.
I gave up because adding all the constraints that are implied on the
coefficients (values and derivatives at the knots) looked difficult, and it
is difficult to get the relevant parameters directly from the scipy splines.
AFAIR
and I was hoping for somebody to come along with more background and more
incentive than I had.
Josef
>
>
> > On Sun, May 7, 2017 at 2:02 PM, <josef.pktd at gmail.com> wrote:
> >>
> >>
> >>
> >> On Sun, May 7, 2017 at 2:45 PM, Jared Vacanti <jaredvacanti at gmail.com>
> >> wrote:
> >>>
> >>> I am trying to fit a polynomial to observational data with shape
> >>> restrictions - in this particular case monotonicity (decreasing) of the
> >>> function and an always positive second derivative.
> >>>
> >>> Some of the interpolation classes have a mathematical "built-in"
> >>> restriction - like scipy.interpolate.Rbf's thin-plate roughness penalty
> >>> imposes some restrictions, but it's not explicit or adjustable.
> >>>
> >>> What are my options for imposing boundary conditions or shape
> >>> restrictions on the spline?
> >>>
> >>> I have sample data here:
> >>>
> >>> import pandas as pd
> >>> df = pd.read_csv("https://bpaste.net/raw/3e20878b5237")
> >>>
> >>> or available independently at https://bpaste.net/raw/3e20878b5237
> >>>
> >>> I have tried using a interior point convex optimization solver, but the
> >>> results seem to be numerically finicky. Are there other alternatives?
> >>
> >>
> >> As far as I know, pchip is the only one with monotonicity constraints
> >> https://docs.scipy.org/doc/scipy/reference/generated/
> scipy.interpolate.pchip_interpolate.html
> >>
> >> Josef
> >>
> >>
> >>>
> >>>
> >>> _______________________________________________
> >>> SciPy-User mailing list
> >>> SciPy-User at python.org
> >>> https://mail.python.org/mailman/listinfo/scipy-user
> >>>
> >>
> >>
> >> _______________________________________________
> >> SciPy-User mailing list
> >> SciPy-User at python.org
> >> https://mail.python.org/mailman/listinfo/scipy-user
> >>
> >
> >
> > _______________________________________________
> > SciPy-User mailing list
> > SciPy-User at python.org
> > https://mail.python.org/mailman/listinfo/scipy-user
> >
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at python.org
> https://mail.python.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20170507/74eefa99/attachment.html>
More information about the SciPy-User
mailing list