csaps icon indicating copy to clipboard operation
csaps copied to clipboard

Spline from auto-computed smooth with normalizedsmooth=True doesn't match using that smooth value directly

Open ryan-feeley opened this issue 9 months ago • 1 comments

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])

ryan-feeley avatar Sep 25 '23 05:09 ryan-feeley