cos_sim: Cosine similarity function

View source: R/cos_sim.R

cos_simR Documentation

Cosine similarity function

Description

Calculate the cosine similarity between two vectors of the same length. The cosine similarity is a value between 0 (distinct) and 1 (identical) and indicates how much two vectors are alike.

Usage

cos_sim(x, y)

Arguments

x

Vector 1 of length n

y

Vector 2 of length n

Value

Cosine similarity value; a value between 0 and 1

Examples

x <- c(1.1, 2.1, 0.2, 0.1, 2.9)
y <- c(0.9, 1.9, 0.5, 0.4, 3.1)
cos_sim(x, y)

UMCUGenetics/MutationalPatterns documentation built on Nov. 24, 2022, 4:31 a.m.