espdev / csaps

Cubic spline approximation (smoothing)
https://csaps.readthedocs.io
MIT License
164 stars 27 forks source link

Duplicate x values will cause an error #39

Closed randomizedthinking closed 3 years ago

randomizedthinking commented 3 years ago

The current implementation cannot handle duplicated x values. In practice, it is common that we observe multiple y-values at the same x value.

espdev commented 3 years ago

Hello,

X-values must strictly monotonically increase or decrease. In other cases we cannot solve the equations to compute the spline.

You need to remove duplicate values from your dataset. You can use numpy.unique function for example.

If you have multiple Y-values at the same X-value you need to use parametrization: x = u(t); y = v(t) where t is strictly monotonically increase or decrease. See multivariate smoothing examples.