Learn R Programming

USP (version 0.1.2)

coeffs: Calculate coefficients of a function's series expansion

Description

This function is used in InfKern to produce the kernel matrix from functional data defined on the interval \([0,1]\). For further details see Section 7.4 of BKS2020USP.

Usage

coeffs(X, Ntrunc)

Arguments

X

The discretised functions whose coefficients are required. This should be a matrix with one row per function, and with \(Ndisc\) columns, where \(Ndisc\) is the grid size of the discretisation.

Ntrunc

The number of coefficients that are required. The function returns coefficients 1,...,\(Ntrunc\).

Value

The coefficients of \(X\) in its expansion in terms of sine functions. See BKS2020USP for more detail.

References

BKS2020USP

Examples

Run this code
# NOT RUN {
t=seq(from=0,to=1,length.out=1000); X=t^2
U=coeffs(X,100)[1,]; L=5
plot(t,X,type="l")
approx=rep(0,1000)
for(l in 1:L){
approx=approx+qnorm(U[l])*sqrt(2)*sin((l-1/2)*pi*t)/((l-1/2)*pi)
lines(t,approx,col=l+1)
}
# }

Run the code above in your browser using DataLab