You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The order k in this package appears to differ from the corresponding usage in other packages such as Dierckx or in scipy.interpolate (which also uses Dierckx I believe). It appears that k here is somewhat equivalent to k+1 in these packages. For example, in scipy:
In [1]: fromscipyimportinterpolateIn [2]: knots= [0,0,1,2,3,4,4]; k=2; c= [1,0,0,0,0];
In [3]: interpolate.BSpline(knots, c, k)(1)
Out[3]: array(0.5)
In [4]: c= [0,1,0,0,0];
In [5]: interpolate.BSpline(knots, c, k)(1)
Out[5]: array(0.5)
In Dierckx,
julia> k =2; breakpoints =0:4;
julia> t =vcat([breakpoints[1] for i in1:k], breakpoints[2:end-1], [breakpoints[end] for i =1:k])
7-element Array{Int64,1}:0012344
julia> c = [1,0,0,0,0];
julia> Dierckx.Spline1D(t, c, k, 0, 0)(1) # matches with scipy0.5# comparing with this package
julia> basis =BSplineBasis(k, breakpoints); knots(basis) == t
true
whereas in this package
julia> basis =BSplineBasis(2, 0:4)
5-element BSplineBasis{UnitRange{Int64}}:
order:2
breakpoints:0:4
julia>knots(basis)
7-element BSplines.KnotVector{Int64,UnitRange{Int64}}:0012344
julia>bsplines(basis, 1)
2-element OffsetArray(::Array{Float64,1}, 2:3) with eltype Float64 with indices 2:3:1.00.0
julia> basis =BSplineBasis(3, 0:4)
6-element BSplineBasis{UnitRange{Int64}}:
order:3
breakpoints:0:4
julia>knots(basis)
9-element BSplines.KnotVector{Int64,UnitRange{Int64}}:000123444
julia>bsplines(basis, 1)
3-element OffsetArray(::Array{Float64,1}, 2:4) with eltype Float64 with indices 2:4:0.50.50.0
Using order=3 in this package leads to values that seem to match the results for k=2 in scipy, although the knots differ as expected at the edges. I wonder if these differences could be explained in the documentation?
The text was updated successfully, but these errors were encountered:
You are correct: what scipy.interpolate and Dierckx call k is equivalent to k+1 in this package. In Dierckx and scipy.interpolate, k refers to the degree of the B-splines, not the order (as in this package). A B-spline of order k is a piecewise polynomial of degree k-1. It is unfortunate that the letter k is used sometimes for the order and sometimes for the degree.
It would indeed be good to add a note about that to the documentation.
The order
k
in this package appears to differ from the corresponding usage in other packages such asDierckx
or inscipy.interpolate
(which also uses Dierckx I believe). It appears thatk
here is somewhat equivalent tok+1
in these packages. For example, in scipy:In
Dierckx
,whereas in this package
Using
order=3
in this package leads to values that seem to match the results fork=2
in scipy, although the knots differ as expected at the edges. I wonder if these differences could be explained in the documentation?The text was updated successfully, but these errors were encountered: