I've been triying several packages to compute the orthonormal Gegenbauer polynomials basis which seems to be orthonormal at [-1,1]. Using the package midasmlI get however a different result:
library(midasml)
x <- seq(-1, 1, length.out = 100)
matplot(B <- gb(degree = 3, alpha = 1, a = -1, b = 1, jmax = NULL, X = x), type="l")
round(t(B) %*% B, 3) #not orthonormal
any reasonement why this is happening? any suggestions for an alternative approach? Thanks!
Orthonormality doesn't mean that this matrix is orthogonal. It means that the integral from -1 to 1 of
P_i(x)P_j(x)w(x)is 0 ifi != jand 1 ifi = j, wherewis a weight function. The weight function for the Gegenbauer polynomials with parameteralphais(1 - x^2)^(alpha - 1/2).You can get these polynomials with the orthopolynom package.
Here the integral of
P_i(x)²w(x)is not 1 because I tooknormalized = FALSE.