espdev / csaps

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

Automatic Smoothing Result #19

Closed ArthurBook closed 4 years ago

ArthurBook commented 4 years ago

Hi! Thanks for a great package. Is there any source for how the smoothing parameter "smooth" is determined automatically? I can not understand where in the code that it is written? Could you help me by providing the source for the algorithm that is used, or maybe describe here the logic behind it or where in the code that I can find it?

This could be very useful to add to the docs as well?

Thanks a lot in advance.

espdev commented 4 years ago

Hi Arthur,

In the project the method from MATLAB csaps function is used (it is not the original method from the book and PGS).

See the code: https://github.com/espdev/csaps/blob/a05249b733c426b72c5ee669cd33cbff7682b01a/csaps/_sspumv.py#L211-L222

https://github.com/espdev/csaps/blob/a05249b733c426b72c5ee669cd33cbff7682b01a/csaps/_sspumv.py#L248-L261

In other words, I will quote MATLAB documentation:

The favorable range for p is often near 1/(1 + h3/6), where h is the average spacing of the data sites. The function chooses a default value for p within this range.

link (see "P - Smoothing parameter" section)

ArthurBook commented 4 years ago

Thank you very much for your help!