Say we have K interior knots (t_1 to t_K). We can form K + 1 piecewice polynomials.
If we want to fit a natural cubic spline s(x)
- In regression, we would enforce the 2nd & 3rd derivatives to be 0 on the bounary. This would make the spline to be linear beyond boundary. (See https://stats.stackexchange.com/questions/233232/the-definition-natural-cubic-splines-for-regression The elements of statistical learning)
- s''(t_1) = 0
- s'''(t_1) = 0
- s''(t_K) = 0
- s'''(t_K) = 0
- In interpolation, we have 2 addtional end points t_0 & t_{K+1}. The spline would have to match the values on all K + 2 points. And we enforce the 2nd derivative to be 0 on the boundary.
- s''(t_0) = 0
- s''(t_{K+1}) = 0
Note here we have 2 different definitions about natural splines. Both definitions have the same degree of freedom K. However I struggle to understand whether the third derivative is needed for a natural spline.