cosine: Calculate the cosine of two vectors

Description Usage Arguments Details Value Author(s) Examples

View source: R/r-utility-cosine.R

Description

This function calculates the cosine of the angle between two numeric vectors. It is used in examples presented in the book Cichosz, P. (2015): Data Mining Algorithms: Explained Using R. See Appendix B or http://www.wiley.com/go/data_mining_algorithms for more details.

Usage

1
cosine(v1, v2)

Arguments

v1

a numeric vector

v2

a numeric vecor

Details

The cosine of the angle between v1 and v2 is calculated as their dot product divided by the product of their L2 norms.

Value

The cosine of the angle between v1 and v2.

Author(s)

Pawel Cichosz <p.cichosz@elka.pw.edu.pl>

Examples

1
2
3
4
cosine(1:5, 1:5)
cosine(1:5, 5:1)
cosine(1:5, -1:-5)
cosine(1:5, rep(3,5))

42n4/dmr.util documentation built on May 20, 2019, 2:02 p.m.