Represents a cubic spline with nodes at \((x_i, y_i)\) computed with the smoothing cubic spline algorithm of Schoenberg [41],. More...
Public Member Functions | |
| SmoothingCubicSpline (double[] x, double[] y, double[] w, double rho) | |
| Constructs a spline with nodes at \((x_i, y_i)\), with weights. | |
| SmoothingCubicSpline (double[] x, double[] y, double rho) | |
| Constructs a spline with nodes at \((x_i, y_i)\), with weights \(= 1\) and smoothing factor \(\rho\) = rho. | |
| double | evaluate (double z) |
| Evaluates and returns the value of the spline at \(z\). | |
| double | integral (double a, double b) |
| Evaluates and returns the value of the integral of the spline from. | |
| double | derivative (double z) |
| Evaluates and returns the value of the first derivative of the spline at \(z\). | |
| double | derivative (double z, int n) |
| Evaluates and returns the value of the n-th derivative of the spline at \(z\). | |
| double[] | getX () |
| Returns the \(x_i\) coordinates for this spline. | |
| double[] | getY () |
| Returns the \(y_i\) coordinates for this spline. | |
| double[] | getWeights () |
| Returns the weights of the points. | |
| double | getRho () |
| Returns the smoothing factor used to construct the spline. | |
| Polynomial[] | getSplinePolynomials () |
| Returns a table containing all fitting polynomials. | |
| int | getFitPolynomialIndex (double x) |
| Returns the index of \(P\), the. | |
Represents a cubic spline with nodes at \((x_i, y_i)\) computed with the smoothing cubic spline algorithm of Schoenberg [41],.
[197] . A smoothing cubic spline is made of \(n+1\) cubic polynomials. The \(i\)th polynomial of such a spline, for \(i=1,…,n-1\), is defined as \(S_i(x)\) while the complete spline is defined as
\[ S(x) = S_i(x), \qquad\mbox{ for }x\in[x_{i-1}, x_i]. \]
For \(x<x_0\) and \(x>x_{n-1}\), the spline is not precisely defined, but this class performs extrapolation by using \(S_0\) and \(S_n\) linear polynomials. The algorithm which calculates the smoothing spline is a generalization of the algorithm for an interpolating spline. \(S_i\) is linked to \(S_{i+1}\) at \(x_{i+1}\) and keeps continuity properties for first and second derivatives at this point, therefore \(S_i(x_{i+1})=S_{i+1}(x_{i+1})\), \(S’_i(x_{i+1})=S’_{i+1}(x_{i+1})\) and \(S"_i(x_{i+1})=S"_{i+1}(x_{i+1})\).
The spline is computed with a smoothing parameter \(\rho\in[0, 1]\) which represents its accuracy with respect to the initial \((x_i, y_i)\) nodes. The smoothing spline minimizes
\[ L = \rho\sum_{i=0}^{n-1}{w_i}\left({y_i - S_i(x_i)}\right)^2 + (1-\rho)\int_{x_0}^{x_{n-1}}\left(S"(x)\right)^2dx \]
In fact, by setting \(\rho= 1\), we obtain the interpolating spline; and we obtain a linear function by setting \(\rho= 0\). The weights \(w_i>0\), which default to 1, can be used to change the contribution of each point in the error term. A large value \(w_i\) will give a large weight to the \(i\)th point, so the spline will pass closer to it. Here is a small example that uses smoothing splines:
Definition at line 88 of file SmoothingCubicSpline.java.
| umontreal.ssj.functionfit.SmoothingCubicSpline.SmoothingCubicSpline | ( | double[] | x, |
| double[] | y, | ||
| double[] | w, | ||
| double | rho ) |
Constructs a spline with nodes at \((x_i, y_i)\), with weights.
\(w_i\) and smoothing factor \(\rho\) = rho. The \(x_i\) must be sorted in increasing order.
| x | the \(x_i\) coordinates. |
| y | the \(y_i\) coordinates. |
| w | the weight for each point, must be \(> 0\). |
| rho | the smoothing parameter |
| IllegalArgumentException | if `x`, `y` and `z` do not have the same length, if rho has wrong value, or if the spline cannot be calculated. |
Definition at line 108 of file SmoothingCubicSpline.java.
| umontreal.ssj.functionfit.SmoothingCubicSpline.SmoothingCubicSpline | ( | double[] | x, |
| double[] | y, | ||
| double | rho ) |
Constructs a spline with nodes at \((x_i, y_i)\), with weights \(= 1\) and smoothing factor \(\rho\) = rho.
The \(x_i\) must be sorted in increasing order.
| x | the \(x_i\) coordinates. |
| y | the \(y_i\) coordinates. |
| rho | the smoothing parameter |
| IllegalArgumentException | if `x` and `y` do not have the same length, if rho has wrong value, or if the spline cannot be calculated. |
Definition at line 145 of file SmoothingCubicSpline.java.
| double umontreal.ssj.functionfit.SmoothingCubicSpline.derivative | ( | double | z | ) |
Evaluates and returns the value of the first derivative of the spline at \(z\).
| z | argument of the spline. |
Implements umontreal.ssj.functions.MathFunctionWithFirstDerivative.
Definition at line 200 of file SmoothingCubicSpline.java.
| double umontreal.ssj.functionfit.SmoothingCubicSpline.derivative | ( | double | z, |
| int | n ) |
Evaluates and returns the value of the n-th derivative of the spline at \(z\).
| z | argument of the spline. |
| n | order of the derivative. |
Implements umontreal.ssj.functions.MathFunctionWithDerivative.
Definition at line 216 of file SmoothingCubicSpline.java.
| double umontreal.ssj.functionfit.SmoothingCubicSpline.evaluate | ( | double | z | ) |
Evaluates and returns the value of the spline at \(z\).
| z | argument of the spline. |
Implements umontreal.ssj.functions.MathFunction.
Definition at line 155 of file SmoothingCubicSpline.java.
| int umontreal.ssj.functionfit.SmoothingCubicSpline.getFitPolynomialIndex | ( | double | x | ) |
Returns the index of \(P\), the.
umontreal.ssj.functions.Polynomial instance used to evaluate \(x\), in an ArrayList table instance returned by getSplinePolynomials(). This index \(k\) gives also the interval in table X which contains the value \(x\) (i.e. such that \(x_k < x \leq x_{k+1}\)).
Definition at line 280 of file SmoothingCubicSpline.java.
| double umontreal.ssj.functionfit.SmoothingCubicSpline.getRho | ( | ) |
Returns the smoothing factor used to construct the spline.
Definition at line 256 of file SmoothingCubicSpline.java.
| Polynomial[] umontreal.ssj.functionfit.SmoothingCubicSpline.getSplinePolynomials | ( | ) |
Returns a table containing all fitting polynomials.
Definition at line 265 of file SmoothingCubicSpline.java.
| double[] umontreal.ssj.functionfit.SmoothingCubicSpline.getWeights | ( | ) |
Returns the weights of the points.
Definition at line 247 of file SmoothingCubicSpline.java.
| double[] umontreal.ssj.functionfit.SmoothingCubicSpline.getX | ( | ) |
Returns the \(x_i\) coordinates for this spline.
Definition at line 229 of file SmoothingCubicSpline.java.
| double[] umontreal.ssj.functionfit.SmoothingCubicSpline.getY | ( | ) |
Returns the \(y_i\) coordinates for this spline.
Definition at line 238 of file SmoothingCubicSpline.java.
| double umontreal.ssj.functionfit.SmoothingCubicSpline.integral | ( | double | a, |
| double | b ) |
Evaluates and returns the value of the integral of the spline from.
\(a\) to \(b\).
| a | lower limit of integral. |
| b | upper limit of integral. |
Implements umontreal.ssj.functions.MathFunctionWithIntegral.
Definition at line 171 of file SmoothingCubicSpline.java.