[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fwd: [Help-gsl] HELP Please - Example of gsl_bspline_knots
From: |
Atul D. Patil |
Subject: |
Re: Fwd: [Help-gsl] HELP Please - Example of gsl_bspline_knots |
Date: |
Wed, 14 Jul 2010 02:16:00 -0700 (PDT) |
Hi Patric/Francesco,
Thanks for your replies. Earlier I had tried with uniform knots.
On experimental basis, I had taken perfect sinusoidal wave and
catered periodic intermittent X and its related Y values to the code in the
example.
I was expecting code would fill the gaps and give me back all Y values as in
original sinusoidal wave. However it returns me almost a constant Y values.
The sinusoidal wave I am having has: X data ranges from 0 to 11025 and Y
ranges
from 0 to 17000. I had chosen to give 1250 intermittent periodic values on the
curve.
And it returned me constant Y values between ranging 8000 to 8500. Other
parameter value (e.g. ncoeffs, nbreak, interval) I used same as in example.
Any idea where I am going wrong?
Thanks,
Atul
________________________________
From: Francesco Abbate <address@hidden>
To: address@hidden
Cc: address@hidden
Sent: Wed, 14 July, 2010 14:07:38
Subject: Fwd: [Help-gsl] HELP Please - Example of gsl_bspline_knots
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
-------------------------------------------------------------------------------
Re: Help-gsl - HELP Please - Example of gsl_bspline_knotsby Patrick Alkenon
2010-07-13T21:46:26+00:00.
Hi, if I understand your problem correctly, you should be able to use
uniform knots. Non-uniform knots are useful when you have data that is
not spread uniformly in your interval, for example if you have some x
values clustered closely together, then a large gap of no x data, then
another cluster, etc.
If your x data is spread somewhat nicely in your interval, just use
uniform knots and the given example program should work for you if you
just replace the input data with your own.
If your data is not very uniform and you have gaps in the data, then you
should use non-uniform knots. Let me know if this is the case for you
and I can provide further assistance.