inst/snippet/uvec-prob02.R

x <- c(3,4,5,8)
mean(x)
var(x)
l <- c(); P<- c()
for (i in 1:4) {
    l[i] <- as.numeric(x %*% uvec(i,4))      # proj coefficient
    P[[i]] <- l[i] * uvec(i,4)               # proj vector 
}
l                                            # proj coefficients
P                                            # proj vectors
# next two should be the same value
l[2]^2 + l[3]^2 + l[4]^2                          
3 * var(x)

Try the fastR package in your browser

Any scripts or data that you put into this service are public.

fastR documentation built on May 2, 2019, 5:53 p.m.