I\'m having trouble getting scipy.interpolate.UnivariateSpline to use any smoothing when interpolating. Based on the function\'s page as well as some previous posts, I beli
Short answer: you need to choose the value for s
more carefully.
The documentation for UnivariateSpline states that:
Positive smoothing factor used to choose the number of knots. Number of
knots will be increased until the smoothing condition is satisfied:
sum((w[i]*(y[i]-s(x[i])))**2,axis=0) <= s
From this one can deduce that "reasonable" values for smoothing, if you don't pass in explicit weights, are around s = m * v
where m
is the number of data points and v
the variance of the data. In this case, s_good ~ 5e7
.
EDIT: sensible values for s
depend of course also on the noise level in the data. The docs seem to recommend choosing s
in the range (m - sqrt(2*m)) * std**2 <= s <= (m + sqrt(2*m)) * std**2
where std
is the standard deviation associated with the "noise" you want to smooth over.