p.function: A generic function to calculate Legendre polynomials

Description Usage Arguments Author(s) References See Also Examples

View source: R/p.function.R

Description

The function calculates the value of j:th normalized Legendre polynomial at x. This function is a subfunction of IDM.

Usage

1
p.function(j, x)

Arguments

j

an integer giving the rank of the polynomial

x

numeric value between -1 and 1

Author(s)

Anna Kuparinen and Mats Bj<f6>rklund

References

Kirkpatrick M, Lofsvold D, Bulmer M (1990) Analysis of the inheritance, selection and evolution of growth trajectories. Genetics 124:979-993.

See Also

IDM, IDM.bootCI

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# The function is currently defined as
function(j,x){

temp1=1/(2^j)*sqrt((2*j+1)/2)
jj=floor(j/2)

temp2=0
for(i in 0:jj){
temp2b=(-1)^i*factorial(j)/(factorial(i)*factorial(j-i))*factorial(2*j-2*i)/(factorial(j)*factorial(2*j-2*i-j))*x^(j-2*i)
temp2=temp2+temp2b
  }
return(temp1*temp2)
  }

Example output

function (j, x) 
{
    temp1 = 1/(2^j) * sqrt((2 * j + 1)/2)
    jj = floor(j/2)
    temp2 = 0
    for (i in 0:jj) {
        temp2b = (-1)^i * factorial(j)/(factorial(i) * factorial(j - 
            i)) * factorial(2 * j - 2 * i)/(factorial(j) * factorial(2 * 
            j - 2 * i - j)) * x^(j - 2 * i)
        temp2 = temp2 + temp2b
    }
    return(temp1 * temp2)
}

InfDim documentation built on May 1, 2019, 9:09 p.m.