-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions of splines2::mSpline do not sum to for periodic = TRUE and non-equidistant knots #19
Comments
Yes, it is expected behavior for M-spline basis functions regardless of the argument library(splines2)
x <- 0:1000 / 1000
order <- 2
deg <- order - 1
knots <- c(0.00, 0.082, 0.23, 0.47, 1.00)
res <- mSpline(
x,
knots = knots[c(-1, -5)],
degree = deg,
Boundary.knots = c(0, 1),
periodic = TRUE,
intercept = TRUE,
integral = TRUE # check the integral
)
matplot(x, res, type = "l") Created on 2023-03-27 with reprex v2.0.2 |
Thank you for this insight. So, unfortunately, it's not possible to create periodic B-Splines using this package, right? Would you consider adding this functionality? |
No problem. I would refer you to Section 2.2 of 10.6339/21-JDS1020 and see if you can apply (1) to obtain the periodic B-splines from the M-spline counterparts. I will consider adding it to the package. |
Thank you very much. I was unaware of (1), and it works fine (although one has to tweak the simple knot sequence a bit to reflect the periodicity). I'm busy now, but I'll add some code to this issue next week. If you like, I can also add a PR to integrate this into splines2. Ideas I came up with are:
|
Glad to hear that (1) works! Thank you for expressing interest in submitting a PR! I have very similar ideas regarding this feature request. We can construct periodic B-splines based on M-splines inside |
So, unfortunately, I have barely touched template classes yet, so implementing one for the spline functions is out of scope for me now.
The above can be executed using |
Thanks for the reference code! I will let you know after I implement the |
I added |
Hi @wenjie2wang,
Sorry to bother you again concerning
splines2::mSpline
. I noticed that the spline functions do not sum to 1 ifperiodic = TRUE
and non-equidistant knots are used. Consider the following reprex:Do you know if this is the supposed behavior? For my application, I need the functions to sum to one.
Thank you very much.
Best, BerriJ
The text was updated successfully, but these errors were encountered: