Constrained smoothing of noisy data using splines in tension
------------------------------------------------------------

Reference
---------

N. A. Teanby (2007)
"Smoothing Noisy Data Using Splines in Tension"
Mathematical Geology, 39 (3), 419-434

Matlab routines to do the fitting:
----------------------------------

fcbsfit_tension.m		main routine to calculate spline c.f.s and covaraince
fspline.m			value of parametric spline at x
fspline_grad.m		gradient of parametric spline at x
fspline_curv.m		curvature of parametric spline at x

cbsfit.m			driver routine for fcbsfit_tension.m
cbsfit_tradeoff.m		routine to plot a tradeoff curve to find tension


test datasets
-------------

test_synth0.dat			synthetic data from Fig 1a
test_synth.dat			synthetic data from Fig 1c
test_synth_constraints.dat	example constraints for test_synth.dat
test_soh1.dat			magnetic data from Fig 4


input file formats
------------------

datafile:

in columns of (x,y,dy)

constraint file:

in columns of (x0,y0,ctype)
where x0 and y0 are the constraints and ctype indicates the kind of contraint according to
0 = y
1 = dy/dx
2 = d2y/dx2

eg. (test_synth_constraints.dat)
2.75 4.0  0       => fitted curve must pass through point (2.75,4.0)
1.0  0.0  1       => fitted curve must have grad = 0 at x=1
4.5  0.0  1       => fitted curve must have grad = 0 at x=4.5


examples
--------

for the examples in Teanby 2007 the following parameters were used:

test_synth0.dat		gamma = 2.5652
test_synth.dat		gamma = 2.0442
test_soh1.dat		gamma = 0.0018

these tensions were found using cbsfit_tradeoff.m with ngamma = 30 and
test_synth0.dat		gamma_step = 0.25
test_synth.dat		gamma_step = 0.25
test_soh1.dat		gamma_step = 0.0001

gamma_step was found using trial and error until the range of the resulting chi2 was large enough to cover either chi2/n = 1 or chi2 = chi2(gamma=0) + chi2(gamma=0)/n

for test_synth.dat if the contraints file test_synth_constraints.dat is used the optimum tension was gamma = 1.6530



