csaps
csaps copied to clipboard
Spline from auto-computed smooth with normalizedsmooth=True doesn't match using that smooth value directly
Hi, thanks for this package.
I stumbled across some behavior I didn't expect. In the following code, I'm computing a smoothing factor automatically with normalizedsmooth=True
. If I then use the resulting smooth
value, keeping normalizedsmooth=True
, the smoothed result is different. Any idea why?
import numpy as np
from csaps import csaps
n = 25
x = np.linspace(-5., 5., n)
y = np.exp(-(x/2.5)**2) + (np.random.rand(n) - 0.2) * 0.3
xi = np.linspace(-5., 5., 150)
is_normalized = True
# Smooth data and compute smoothing factor automatically
yi_auto, smooth = csaps(x, y, xi, normalizedsmooth=is_normalized)
# Smooth data with smoothing factor 0.85
yi_explicit = csaps(x, y, xi, smooth=smooth, normalizedsmooth=is_normalized)
print(np.array_equal(yi_auto, yi_explicit))
print(yi_auto[0], yi_explicit[0])
Hello @ryan-feeley,
Thanks for the report. I will check the code.