67.5k views
3 votes
"I need the following for R, not

Python
A quadratic B-spline is a smooth quadratic function, which can be defined interms of truncated polynomials.

B delta (x)= 1/(2delta ^ 2) ((x-0) + ^ 2 -3(x- delta) + ^ 2 +3(x-2 delta) + ^ 2 -(x-3 delta) + ^ 2 )

Write a function 'bspline' which takes arguments x and & and returns B_{delta}(x) Thedefault value of & should be 1. Compute the value of bspline (19, 10) andbspline (1:20, 5)

1 Answer

3 votes

Final answer:

A quadratic B-spline function B_{δ}(x) is defined using truncated polynomials. To compute values for bspline(19, 10) and bspline(1:20, 5), one would use the bspline function, substituting the appropriate values for x and δ.

Step-by-step explanation:

The quadratic B-spline function, Bδ(x), can be defined using truncated polynomials as follows:

Bδ(x) = \frac{1}{2δ^2} ((x-0)_{+}^2 - 3(x-δ)_{+}^2 + 3(x-2δ)_{+}^2 - (x-3δ)_{+}^2)

Where (x-a)_{+} means that the expression is taken as x-a if x is greater than a, and 0 otherwise. This ensures the function is piecewise and its value is 'truncated' or set to zero whenever x is less than a.

The B-spline function is smooth and defined piecewise. To write the function 'bspline', we could use the following pseudo-code:

function bspline(x, δ=1){ return 1/(2*δ^2) * (max(0, x-0)^2 - 3*max(0, x-δ)^2 + 3*max(0,x-2*δ)^2 - max(0,x-3*δ)^2); }

To calculate bspline(19, 10) and bspline(1:20, 5), you would substitute x with 19 and delta with 10 for the first case, and x with 1 through 20 and delta with 5 for the second case, respectively, in the bspline function to obtain the values.

User Dylan Hogg
by
7.5k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories