[SciPy-User] B-spline basis functions?

Nathaniel Smith njs@pobox....
Tue Jul 31 10:37:26 CDT 2012


Hi all,

I'd like to be able to do spline regression in patsy[1], which means
that I need to be able to compute b-spline basis functions. I am not
an initiate into the mysteries of practical spline computations, but I
*think* the stuff in scipy.signal is not quite usable as is, because
it's focused on doing interpolation directly rather than exposing the
basis functions themselves?

Specifically, to achieve feature parity with R [2], I need to be able to take
  - an arbitrary order
  - an arbitrary collection of knot positions (which may be irregularly spaced)
  - a vector x of points at which to evaluate the basis functions
and spit out the value of each spline basis function evaluated at each
point in the x vector.

It looks like scipy.signal.bspline *might* be useful, but I can't
quite tell? Or alternatively someone might have some code lying around
to do this already?

Basically I have a copy of Schumaker here and I'm hoping someone will
save me from having to read it :-).

-n

[1] https://github.com/pydata/patsy/
[2] http://stat.ethz.ch/R-manual/R-devel/library/splines/html/bs.html
    http://stat.ethz.ch/R-manual/R-devel/library/splines/html/ns.html


More information about the SciPy-User mailing list