I am attempting to write
R code for cubic splines to connect points on a graph. Specifically, I am attempting to reproduce Figure 3.3 of Wood (2006)
Generalized Additive Models: An Introduction with R (page 124) where he uses seven cubic splines to connect eight points. I am starting with only three or four data points and have modified their values, so they may not closely match his data.
I have written
R code based on equations provided at
I believe I have successfully programmed the equations provided in
Wikipedia for the example there with three data points. However, I am unsure whether I have correctly modified that code for four data points.
What is the name of the algorithm shown in the above
Wikipedia article and used in the example there? Is there a readily accessible citation for that algorithm?
I cannot see where the equations in the
Wikipedia example follow from the derivation of the algorithm. Specifically, where do the equations for
a22 come from and what do
The plot created by my
R code for three data points appears to match the plot provided in the
Wikipedia example. However, I cannot reproduce that plot using the
spline function in
Wolphram-Alpha creates a plot that appears to match the plot returned by the
FMM method in the
spline function in
R. What does
FMM stand for and what would be a good citation for that method?
I suspect the reason the plot I obtain and the example plot in
Wikipedia does not match the plot returned by
Wolphram-Alpha or by the
FMM function in
R is that the example in
Wikipedia uses two different cubic splines joined together at the middle data point, but that
Wolphram-Alpha / FMM in
R create one polynomial equation using all data points simultaneously. Is that correct?
In other words, I suspect
Wikipedia and my
R code use spline interpolation, but that
Wolfram-Alpha and the
FMM method in
R use polynomial interpolation. Is that correct?
Originally I was hoping for verification that I had generated the correct equations for four data points based on the equations in
Wikipedia for three data points. However, I have now shifted my focus to the questions in the preceding paragraphs and removed my
If I can learn the answers to the questions above perhaps I can make progress following the algorithm shown in the above
Wikipedia article and then perhaps post a programming question on Stack Overflow. Thank you for any answers to those questions.
So far the best reference I have found is
Numerical Computing with MATLAB by Cleve Moler, available here:
If I make substantial progress I will post what I learn as an answer.