PolyShift: Transformation of polynomial coefficients to change origin...

View source: R/gsp_util.R

PolyShiftR Documentation

Transformation of polynomial coefficients to change origin Useful to equate polynomial coefficients for a periodic spline

Description

If coef is a vector of coefficients for a polynomial of the form coef[1] + coef[2]*x + coef[3]*x^2 + coef[4]*x^3 , then coef_tr <- PolyShift(a, 4) %*% coef is a vector of coefficients for the same polynomial centered at a, i.e. coef_tr[1] + coef_tr[2]*(x-a) + coef_tr[3]*(x-a)^2 + coef_tr[4]*(x-a)^3 ,

Usage

PolyShift(a, n)

Arguments

a

center for transformed polynomial

n

number of coefficients

Examples

coefs <- c(3,2,4)
x <- 3
n <- length(coefs)
a <- 2
sum( coefs * x ^ (0:(n-1))) 
sum( PolyShift(a,n)%*%coefs * (x -a)^(0:(n-1)))

gmonette/spida2 documentation built on Aug. 11, 2024, 7:52 p.m.