[SciPy-User] Spline Interpolation with non continuous data

Xavier Barthelemy xabart at gmail.com
Tue Jun 25 19:18:10 EDT 2013


Yes, or use tension spline, with the W parameter. It will stop (well, not
stop, but limit) the natural spline to oscillate and have the gibbs
phenomena.

I found that some time ago on stackoverflow.

when I want matlab-like medium tension I use W=sqrt(weights)
when I want high tension, I use W=weights.



#In short, to match matlab's error calculation, you need to pass "w" to
splrep or UnivariateSpline, where w = np.sqrt(trapz_weights(x))
#
def trapz_weights(x):
    dx = np.diff(x)
    w = np.empty(x.shape)
    w[1:-1] = (dx[1:] + dx[:-1])/2.
    w[0] = dx[0] / 2.
    w[-1] = dx[-1] / 2.
    return w

Xavier


2013/6/26 Joon Ro <joonhyoung.ro at gmail.com>

> On Sat, Jun 22, 2013 at 9:14 AM, Franz Engel <franz_lambert_engel at yahoo.de
> > wrote:
>
>>
>>
>> I try to interpolated a spline throw a dataset (the record of a robot
>> motion path). Usually it works really good, always when the robot drives
>> without stops. But if the robot stops he moves a little bit backwards. If
>> this happens I can’t use my “normal” method with the
>> interpolate.UnivariateSpline-function(
>> http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.UnivariateSpline.html),
>> because the robot motion is not longer continuously.
>>
> Hi,
>
> I am not familiar how your function looks like, but it sounds like you
> should look for shape-preserving interpolation like monotone cubic Hermite
> interpolation.
>
> Best,
> Joon
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


-- 
 « Quand le gouvernement viole les droits du peuple, l'insurrection est,
pour le peuple et pour chaque portion du peuple, le plus sacré des droits
et le plus indispensable des devoirs »

Déclaration des droits de l'homme et du citoyen, article 35, 1793
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130626/a623c34f/attachment.html>


More information about the SciPy-User mailing list