Learn R Programming

ForImp (version 1.0.3)

vcosw: Cosine of the angle between two vectors

Description

The function calculates the cosine of the angle between two vectors, defined as the inner product of the vectors divided by the product of their euclidean norms

Usage

vcosw(v, w)

Arguments

v
a vector
w
a vector, of the same length of v

Value

The cosine of the angle between the two vectors

See Also

Ferrari P.A., Annoni P., Barbiero A., Manzi G. (2011) An imputation method for categorical variables with application to nonlinear principal component analysis, Computational Statistics & Data Analysis, vol. 55, issue 7, pages 2410-2420, http://www.sciencedirect.com/science/article/pii/S0167947311000521

Examples

Run this code
a<-1:10
b<-2:11
vcosw(a,b)
#
e<-c(1,2,3)
f<-c(3,-3,1)
vcosw(e,f)
# e and f are orthogonal vectors!

Run the code above in your browser using DataLab