Skip to content

Knots are not correctly calculated in BSplineApprox with knotVecType = :Average #439

Open
@heliosdrm

Description

@heliosdrm

According to the the notes in the code of BSplineApprox, the option knotVecType = :Uniform is not recommended if it is used with the chord length method for global interpolation. However, the alternative knotVecType = :Average does not produce a correct set of knots. Namely:

julia> x = 0:0.1:10;

julia> y = randn(101); # or anything else

julia> sp = BSplineApprox(y, x, 3, 20, :ArcLen, :Average)
BSplineApprox with 101 points, with degree 3, number of control points 20

[... snip ...]

julia> sp.k
24-element Vector{Float64}:
 0.0
 0.0
 0.0
 0.0
 0.041544922773446444
 0.05312314970883667
 0.062325767284134394
 0.07163762461960164
 0.0816032331679999
 0.09584179757523949
 
 0.16196790599023062
 0.16692261841638856
 0.17258753155720719
 0.17997404351857807
 0.18633410292440233
 0.19189122073158726
 1.0
 1.0
 1.0
 1.0

As can be seen, the "internal" knots start at 0.04 (close to the starting point), but end at 0.19 (very far from the endpoint that is 1.0). Therefore, all the knots are concentrated at the beginning of the fitted series, instead of spread along the whole domain of x.

This is happening with DataInterpolations v8.1.0, in a clean environment.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions