Skip to content

Commit

Permalink
update docs for normalizedsmooth option
Browse files Browse the repository at this point in the history
  • Loading branch information
espdev committed Oct 5, 2021
1 parent a2318cb commit 00508c1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions csaps/_shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def csaps(xdata: Union[UnivariateDataType, NdGridDataType],
If True, the smooth parameter is normalized such that results are invariant to xdata range
and less sensitive to nonuniformity of weights and xdata clumping
.. versionadded:: 1.1.0
Returns
-------
Expand Down
2 changes: 2 additions & 0 deletions csaps/_sspndg.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ class NdGridCubicSmoothingSpline(ISmoothingSpline[
If True, the smooth parameter is normalized such that results are invariant to xdata range
and less sensitive to nonuniformity of weights and xdata clumping
.. versionadded:: 1.1.0
"""

__module__ = 'csaps'
Expand Down
3 changes: 3 additions & 0 deletions csaps/_sspumv.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class CubicSmoothingSpline(ISmoothingSpline[
normalizedsmooth : [*Optional*] bool
If True, the smooth parameter is normalized such that results are invariant to xdata range
and less sensitive to nonuniformity of weights and xdata clumping
.. versionadded:: 1.1.0
"""

__module__ = 'csaps'
Expand Down
34 changes: 34 additions & 0 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,40 @@ For example, the following code will raise ``ValueError`` without ``axis`` param
``axis`` parameter is ignored in ND-gridded data cases.


.. _tutorial-normalizedsmooth:

Smooth normalization
~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 1.1.0

We can use ``normalizedsmooth`` option to normalize smooth parameter.
If ``normalizedsmooth`` is True, the smooth parameter is normalized such that results are invariant to xdata range
and less sensitive to nonuniformity of weights and xdata clumping.

Let's show it on a simple example.

.. plot::

x1, y = univariate_data(seed=1327)
x2 = x1 * 10

xi1 = np.linspace(x1[0], x1[-1], 150)
xi2 = np.linspace(x2[0], x2[-1], 150)

yi1 = csaps(x1, y, xi1, smooth=0.8)
yi2 = csaps(x2, y, xi2, smooth=0.8)

yi1_n = csaps(x1, y, xi1, smooth=0.8, normalizedsmooth=True)
yi2_n = csaps(x2, y, xi2, smooth=0.8, normalizedsmooth=True)

f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(8, 6))
ax1.plot(x1, y, 'o', xi1, yi1, '-')
ax2.plot(x2, y, 'o', xi2, yi2, '-')
ax3.plot(x1, y, 'o', xi1, yi1_n, '-')
ax4.plot(x2, y, 'o', xi2, yi2_n, '-')


Computing Spline Without Evaluating
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 00508c1

Please sign in to comment.