|
vector | build_b_spline (array[] real t, array[] real ext_knots, int ind, int order) |
|
B-Spline Basis interpolation
"Splines In Stan", Milad Kharratzadeh, Oct. 23, 2017,
https://github.com/milkha/Splines_in_Stan/blob/master/splines_in_stan.pdf
accessed Feb. 9, 2021.
vector
build_b_spline(array[] real t, array[] real ext_knots,
int ind,
int order);
vector
build_b_spline(array[] real t, array[] real ext_knots,
int ind,
int order) {
int N = size(t);
vector[N] b_spline;
vector[N] w1 = rep_vector(0, N);
vector[N] w2 = w1;
if (order == 1) {
for (i in 1 : N)
b_spline[i] = (ext_knots[ind] <= t[i]) && (t[i] < ext_knots[ind + 1]);
} else {
if (ext_knots[ind] != ext_knots[ind + order - 1])
w1 = (to_vector(t) - rep_vector(ext_knots[ind], N))
/ (ext_knots[ind + order - 1] - ext_knots[ind]);
if (ext_knots[ind + 1] != ext_knots[ind + order])
w2 = 1
- (to_vector(t) - rep_vector(ext_knots[ind + 1], N))
/ (ext_knots[ind + order] - ext_knots[ind + 1]);
}
return b_spline;
}
vector build_b_spline(array[] real t, array[] real ext_knots, int ind, int order)
Definition: build_b_spline.stanfunctions:26
◆ build_b_spline()
vector build_b_spline |
( |
array[]real |
t, |
|
|
array[]real |
ext_knots, |
|
|
int |
ind, |
|
|
int |
order |
|
) |
| |
- Copyright
- Milad Kharratzadeh
https://github.com/milkha/Splines_in_Stan/blob/master/b_spline.stan
Accessed Feb. 9, 2021
- Parameters
-
t | Array of real numbers, the points at which the b_spline is calculated |
ext_knots | Array of real numbers, the set of extended knots |
ind | Int the index of the b_spline |
order | Int the order of the b-spline |
- Returns
- vector of B-spline bases