Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

poly.orth

Construct Orthogonal Polynomials


Description

Construct the orthogonal polynomials on a given vector, up to a specified degree.

Usage

poly.orth(x, degree = length(unique(x)) - 1, norm = TRUE)

Arguments

x

a numeric vector of abscissae. When evaluated at x the polynomials will generate an orthonormal set.

degree

maximum degree required. The default is one fewer than the number of distinct values in x, which is maximum possible.

norm

a logical indicating whether the polynomials should be normalized.

Value

A list of class "polylist" of objects of class "polynomial" of degree 1, 2, ..., degree.

Examples

x <- rep(1:4, 1:4)		# x with repetitions for weighting
x
## [1] 1 2 2 3 3 3 4 4 4 4
polx <- poly.orth(x, 3)		# calculate orthogonal polynomials
polx
## List of polynomials:
## [[1]]
## 0.3162278 
## 
## [[2]]
## -0.9486833 + 0.3162278*x 
## 
## [[3]]
## 2.139203 - 1.863177*x + 0.3450328*x^2 
## 
## [[4]]
## -5.831564 + 8.80369*x - 3.803194*x^2 + 0.4930066*x^3 
v <- sapply(polx, predict, x)   # orthonormal basis
round(crossprod(v), 10)	        # check orthonormality

polynom

A Collection of Functions to Implement a Class for Univariate Polynomial Manipulations

v1.4-0
GPL-2
Authors
Bill Venables [aut, cre] (S original), Kurt Hornik [aut] (R port), Martin Maechler [aut] (R port)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.