sablib
Loading...
Searching...
No Matches
pspline.cpp File Reference

Smoothing with penalized Spline(P-Spline)(implementation). More...

#include "../misc/diff.h"
#include "pspline.h"

Go to the source code of this file.

Functions

const std::vector< double > sablib::PSpline (const std::vector< double > &y, const unsigned int knots_num, const unsigned int degree=3, const unsigned int s=2, const double lambda=1.0)
 Smoothes the input data using P-Splines (Penalized B-Splines).

Detailed Description

Smoothing with penalized Spline(P-Spline)(implementation).

Author
Izadori

Definition in file pspline.cpp.

Function Documentation

◆ PSpline()

const std::vector< double > sablib::PSpline ( const std::vector< double > & y,
const unsigned int knots_num,
const unsigned int degree = 3,
const unsigned int s = 2,
const double lambda = 1.0 )

Smoothes the input data using P-Splines (Penalized B-Splines).

This function applies a B-Spline basis with a difference penalty on the coefficients to achieve smoothing of the input data.

Parameters
yThe input data points to be smoothed.
knots_numThe number of internal knots for the B-Spline basis.
degreeThe degree of the B-Spline basis (default is 3, cubic spline).
sThe order of the difference penalty (default is 2).
lambdaThe smoothing parameter (default is 1.0). Larger values result in smoother curves.
Returns
A vector containing the smoothed data points.
Exceptions
std::invalid_argumentOne or more parameters are wrong.

Definition at line 15 of file pspline.cpp.

References sablib::BSpline< Scalar >::DesignMatrix(), and sablib::BSpline< Scalar >::Interpolate().