IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
splinebasis.m
Go to the documentation of this file.
1 %>@ingroup maths
2 %>@file
3 %>@brief Splines transformation matrix
4 %>
5 %> This matrix transforms a dataset into the coefficients for reconstruction using a spline basis. The transformation matrix is therefore the pseudo-inverse <code>B/(B'*B)</code> of the spline basis.
6 %>
7 %> <h3>References:</h3>
8 %> [1] Jim Ramsay, B. W. Silverman. Functional Data Analysis. 2nd Ed. Springer. 2005.
9 %> [2] J. Ramsay, G. Hooker, and S. Graves, Functional Data Analysis with R and MATLAB. New York: Springer, 2009.
10 %> Function @c create_bspline_basis
11 
12 %
13 %> @param nf Number of features
14 %> @param no_basis Number of basis vectors
15 %> @param breaks =[] Break points. Check reference [1]
16 %> @param order =6 Spline order. Check reference [1]
17 %> @return The pseudo-inverse <code>B/(B'*B)</code> of the spline basis.
18 function L = splinebasis(nf, no_basis, breaks, order)
19 
20 if ~exist('order', 'var')
21  order = 6;
22 end;
23 if ~exist('breaks', 'var') || isempty(breaks)
24  breaks = linspace(1, nf, no_basis-order+2);
25 end;
26 
27 bb = create_bspline_basis([1, nf], no_basis, order, round(breaks));
28 
29 
30 % Now the main task
31 % We gotta get the loadings matrix
32 tt3 = 1:nf;
33 B = eval_basis(tt3, bb);
34 L = B/(B'*B); % L, the "loadings" matrix
function splinebasis(in nf, in no_basis, in breaks, in order)