Cubic Spline Interpolation Periodic with Concatenated Splines

Cubic spline interpolation on a set of points. The first spline was attached to the right end of the interpolation result and the last spline to the beginning. The boundary condition is called periodic.

LaTeX source

\documentclass[11pt]{article}

% graphics
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{fillbetween}

\begin{document}
\begin{tikzpicture}

\pgfplotsset{
scale only axis,
}

\begin{axis}[
xlabel=$x$,
ylabel=$y$,
samples=100,
-1.5 -1.2
-0.2 0
1 0.5
5 1
10 1.2
15 2
20 1
};

\end{document}