[SciPy-user] Re: data smoothing: interpolate.splrep ignores s parameter

val val at vtek.com
Wed Feb 25 17:47:20 CST 2004


Well,
    Maybe, first you'd set up the realistic precision
eps you want.  For now, you have a range of 5 orders
of magnitudes.  Scale your data based on eps and graph
it to see how noisy the data is.  For physical variables,
the noise should be within reasonable range.  Smoothing
'per se' does not help much with unreasonably noisy data.
    Or i'm missing smth?
val


----- Original Message -----
From: "george young" <gry at ll.mit.edu>
To: <scipy-user at scipy.net>
Sent: Wednesday, February 25, 2004 2:21 PM
Subject: [SciPy-user] Re: data smoothing: interpolate.splrep ignores s
parameter


> [[reposting with "rough" data file appended, sorry]]
> [SciPy-0.2.0_alpha_200.4161, Numeric-23.1, Python 2.3.3, x86 Linux]
> My goal really is to smooth some noisy measurement data without messing
> up it's *shape*.  My first attempt was 1d splines.  I did:
>
> from Numeric import *
> import scipy
> f = file('rough')
> data = array([(float(x),float(y)) for (x,y) in [l.split() for l in f]])
> rep = scipy.interpolate.splrep(data[:,0], data[:,1], s=s)
> smooth_y = scipy.interpolate.splev(data[:,0], rep)
>
> "s" is supposed to vary the amount of smoothing.  For s=0, i get
> my original data back, as expected.  But for all other values, including
> the recommended range of (m-sqrt(2.0*m)) to (m+sqrt(2.0*m), I get a
> single, too much smoothed, result.  It seems like splrep is not using
> the "s" value to adjust the splines, except to sense that it's not zero.
>
> Splines may not be the right method anyway, since they tend to warp the
> shape of the curve, and I need to get the data's derivatives.  Is there
> some way to fashion a low pass filter?  It seems like fft should be useful
> here, but I have very little experience with fft's.
>
> -- George Young
>
> "rough" file:
> 0.5 -1.7355e-10
> 0.455 -4.6185e-10
> 0.41 -3.2125e-10
> 0.365 -4.035e-10
> 0.32 2.951e-10
> 0.275 2.628e-10
> 0.23 2.922e-10
> 0.185 -3.1775e-10
> 0.14 -3.3209e-10
> 0.095 -3.6665e-10
> 0.05 -2.7394e-10
> 0.0 2.98e-10
> -0.04 3.228e-10
> -0.085 3.219e-10
> -0.13 4.093e-10
> -0.175 2.7406e-10
> -0.22 1.102e-10
> -0.265 -6.012e-10
> -0.31 -3.9674e-09
> -0.355 -1.2145e-08
> -0.4 -3.9299e-08
> -0.445 -1.2074e-07
> -0.49 -3.2109e-07
> -0.535 -7.3798e-07
> -0.58 -1.4695e-06
> -0.625 -2.548e-06
> -0.67 -3.9104e-06
> -0.715 -5.4895e-06
> -0.76 -7.1758e-06
> -0.805 -8.9267e-06
> -0.85 -1.0675e-05
> -0.895 -1.2425e-05
> -0.94 -1.4115e-05
> -0.985 -1.579e-05
> -1.03 -1.7415e-05
> -1.075 -1.9005e-05
> -1.12 -2.0505e-05
> -1.165 -2.2e-05
> -1.21 -2.346e-05
> -1.255 -2.4885e-05
> -1.3 -2.624e-05
> -1.345 -2.757e-05
> -1.39 -2.886e-05
> -1.435 -3.015e-05
> -1.48 -3.1404e-05
> -1.525 -3.2604e-05
> -1.57 -3.385e-05
> -1.615 -3.498e-05
> -1.66 -3.6105e-05
> -1.705 -3.718e-05
> -1.75 -3.8279e-05
> -1.795 -3.932e-05
> -1.84 -4.033e-05
> -1.885 -4.13e-05
> -1.93 -4.2304e-05
> -1.975 -4.3275e-05
> -2.02 -4.429e-05
> -2.065 -4.5205e-05
> -2.11 -4.6069e-05
> -2.155 -4.697e-05
> -2.2 -4.7825e-05
> -2.245 -4.8639e-05
> -2.29 -4.9515e-05
> -2.335 -5.0319e-05
> -2.38 -5.1094e-05
> -2.425 -5.188e-05
> -2.47 -5.264e-05
> -2.515 -5.3454e-05
> -2.56 -5.4169e-05
> -2.605 -5.4905e-05
> -2.65 -5.5633e-05
> -2.695 -5.6334e-05
> -2.74 -5.7043e-05
> -2.785 -5.7749e-05
> -2.83 -5.8343e-05
> -2.875 -5.9085e-05
> -2.92 -5.9729e-05
> -2.965 -6.0344e-05
> -3.01 -6.094e-05
> -3.055 -6.1564e-05
> -3.1 -6.2104e-05
> -3.145 -6.2749e-05
> -3.19 -6.3348e-05
> -3.235 -6.3956e-05
> -3.28 -6.4414e-05
> -3.325 -6.4958e-05
> -3.37 -6.555e-05
> -3.415 -6.6075e-05
> -3.46 -6.656e-05
> -3.505 -6.71e-05
> -3.55 -6.7603e-05
> -3.595 -6.8083e-05
> -3.64 -6.8623e-05
> -3.685 -6.9048e-05
> -3.73 -6.9518e-05
> -3.775 -6.998e-05
> -3.82 -7.0508e-05
> -3.865 -7.0929e-05
> -3.91 -7.1343e-05
> -3.955 -7.1824e-05
> -4.0 -7.2218e-05
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>



More information about the SciPy-user mailing list