<div>Hi, josef.  If you mean having generic code that automates the process, then you are probably correct: there's just too many degrees of freedom to account for all possibilities in a generic program (at least that's the way it appears to me, too).  But using known math to work out, "by hand," these implications in specific cases prior to using the generic code tools we do have, largely thanks to you, is eminently "do-able." Â Thanks for all you've done for scipy, lo these many years!</div><div><br></div><div>DLG</div><div><br></div><div><div class="gmail_quote"><div>On Sun, May 7, 2017 at 1:37 PM <<a href="mailto:josef.pktd@gmail.com">josef.pktd@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_extra"><div class="gmail_quote">On Sun, May 7, 2017 at 3:34 PM, Evgeni Burovski <span><<a href="mailto:evgeny.burovskiy@gmail.com" target="_blank">evgeny.burovskiy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Sun, May 7, 2017 at 10:12 PM, Jared Vacanti <<a href="mailto:jaredvacanti@gmail.com" target="_blank">jaredvacanti@gmail.com</a>> wrote:<br>
> Are there other techniques of fitting splines (perhaps using scipy.optimize<br>
> ?) where I can impose boundary conditions myself, even outside of the<br>
> options provided in scipy.interpolate?<br>
<br>
</span>FITPACK has some spline fitting with convexity constraints, but I<br>
don't think it's exposed to python:<br>
<br>
<a href="https://github.com/scipy/scipy/blob/master/scipy/interpolate/fitpack/concon.f" rel="noreferrer" target="_blank">https://github.com/scipy/scipy/blob/master/scipy/interpolate/fitpack/concon.f</a><br>
<a href="https://github.com/scipy/scipy/blob/master/scipy/interpolate/fitpack/cocosp.f" rel="noreferrer" target="_blank">https://github.com/scipy/scipy/blob/master/scipy/interpolate/fitpack/cocosp.f</a><br>
<br>
Hyman et al have some discussion of constructing local interpolants<br>
with convexity constraints:<br>
<a href="http://math.lanl.gov/~mac/papers/numerics/DEH89.pdf" rel="noreferrer" target="_blank">http://math.lanl.gov/~mac/papers/numerics/DEH89.pdf</a><br>
and references therein.<br>
<div class="m_-6739484399442727154HOEnZb"><div class="m_-6739484399442727154h5"><br></div></div></blockquote><div><br></div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div>I looked into monotonicity and similar constraints for splines several years ago.</div><div>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.</div><div><br></div><div>AFAIR</div><div>and I was hoping for somebody to come along with more background and more incentive than I had.</div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Josef</div></div></div></div><div><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="m_-6739484399442727154HOEnZb"><div class="m_-6739484399442727154h5">
<br>
<br>
> On Sun, May 7, 2017 at 2:02 PM, <<a href="mailto:josef.pktd@gmail.com" target="_blank">josef.pktd@gmail.com</a>> wrote:<br>
>><br>
>><br>
>><br>
>> On Sun, May 7, 2017 at 2:45 PM, Jared Vacanti <<a href="mailto:jaredvacanti@gmail.com" target="_blank">jaredvacanti@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> I am trying to fit a polynomial to observational data with shape<br>
>>> restrictions - in this particular case monotonicity (decreasing) of the<br>
>>> function and an always positive second derivative.<br>
>>><br>
>>> Some of the interpolation classes have a mathematical "built-in"<br>
>>> restriction - like scipy.interpolate.Rbf's thin-plate roughness penalty<br>
>>> imposes some restrictions, but it's not explicit or adjustable.<br>
>>><br>
>>> What are my options for imposing boundary conditions or shape<br>
>>> restrictions on the spline?<br>
>>><br>
>>> I have sample data here:<br>
>>><br>
>>> import pandas as pd<br>
>>> df = pd.read_csv("<a href="https://bpaste.net/raw/3e20878b5237" rel="noreferrer" target="_blank">https://bpaste.net/raw/3e20878b5237</a>")<br>
>>><br>
>>> or available independently at <a href="https://bpaste.net/raw/3e20878b5237" rel="noreferrer" target="_blank">https://bpaste.net/raw/3e20878b5237</a><br>
>>><br>
>>> I have tried using a interior point convex optimization solver, but the<br>
>>> results seem to be numerically finicky. Are there other alternatives?<br>
>><br>
>><br>
>> As far as I know, pchip is the only one with monotonicity constraints<br>
>> <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.pchip_interpolate.html" rel="noreferrer" target="_blank">https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.pchip_interpolate.html</a><br>
>><br>
>> Josef<br>
>><br>
>><br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> SciPy-User mailing list<br>
>>> <a href="mailto:SciPy-User@python.org" target="_blank">SciPy-User@python.org</a><br>
>>> <a href="https://mail.python.org/mailman/listinfo/scipy-user" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-user</a><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> SciPy-User mailing list<br>
>> <a href="mailto:SciPy-User@python.org" target="_blank">SciPy-User@python.org</a><br>
>> <a href="https://mail.python.org/mailman/listinfo/scipy-user" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-user</a><br>
>><br>
><br>
><br>
> _______________________________________________<br>
> SciPy-User mailing list<br>
> <a href="mailto:SciPy-User@python.org" target="_blank">SciPy-User@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/scipy-user" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-user</a><br>
><br>
_______________________________________________<br>
SciPy-User mailing list<br>
<a href="mailto:SciPy-User@python.org" target="_blank">SciPy-User@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scipy-user" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-user</a><br>
</div></div></blockquote></div></div></div>
_______________________________________________<br>
SciPy-User mailing list<br>
<a href="mailto:SciPy-User@python.org" target="_blank">SciPy-User@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scipy-user" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scipy-user</a><br>
</blockquote></div></div>