[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: [Help-gsl] HELP Please - Example of gsl_bspline_knots
From: |
Francesco Abbate |
Subject: |
Fwd: [Help-gsl] HELP Please - Example of gsl_bspline_knots |
Date: |
Wed, 14 Jul 2010 10:37:38 +0200 |
Hi,
I agree with the suggestion of Patrick, you can use uniform b-splines.
You can actually play with your data and gsl routines using gsl-shell.
Here a sample snippet that:
* create a non-uniform set of data
* fit them using a uniform b-splines
* plot the data and the fitting curve
local xp, r = 0, rng()
x = new(32, 1, function(k) local x = xp + rnd.exponential(r, 0.2); xp
= x; return x end)
y = new(32, 1, |k| sin(x[k])*(1+rnd.gaussian(r, 0.1)))
-- sample code for GSL shell
local x0, x1 = 0, x[32]
p = plot('Simulated non-uniform data')
p:addline(xyline(x,y), 'black', {{'marker', size=4}})
p:show()
b = bspline(x0, x1, 6)
X = b:model(x)
c, cov = mlinear(X, y)
p:addline(fxline(|x| prod(c, b:eval(x))[1], x0, x1))
-- end of code
Francesco