# Spline Theory and Code

On P. Janert's book Data Analysis with Open Source Tools there is a discussion on splines, that they are "constructed from piecewise polynomial functions (typically cubic) that are joined together in a smooth fashion" and in addition "must also satisfy a global smoothness condition by optimizing the functional".

$$J[s] = \alpha \int \bigg(\frac{d^2s}{dt^2}\bigg)^2 dt + (1-\alpha) \sum_i w_i (y_i - s(x_i))^2$$

The first term controls how “wiggly” the spline is overall, because the second derivative measures the curvature of s(t) and becomes large if the curve has many wiggles. The second term captures how accurately the spline represents the data points by measuring the squared deviation of the spline from each data point.

Does anyone know an explanation of the theory and implementation for splines that continues in this vein? Apparently "these smoothness conditions lead to a set of linear equations for the coefficients in the polynomials, which can be solved". Janert's book gives no derivation for this, I was wondering if anyone has references to material or knowledge about the details for this technique hopefully with working Matlab or Python code.

I found a readable explanation here

Thanks,

-