Skip to contents

Computes the Czekanowski index of overlap between two relative-frequency activity profiles \(p\) and \(q\): $$1 - \tfrac{1}{2}\sum_i |p_i - q_i|.$$

Usage

czekanowski_index(p, q)

Arguments

p

Numeric vector of non-negative relative frequencies (typically sums to 1) describing the first biological identity data (e.g. activity, population size, etc) across ordered time bins. Standardized use of time intervals through the manual.

q

Numeric vector of non-negative relative frequencies (same length as p) for the second biological identity across ordered time bins.

Value

A single numeric value in [0, 1] where 0 indicates no overlap and 1 indicates identical profiles.

Details

Inputs should be on a comparable scale; if your data are raw counts, rescale rows to proportions first (see rescale_matrix()).

Examples

set.seed(1)
n <- 6
p <- rmultinom(1, 20, rep(1, n))[,1]; p <- p / sum(p)
q <- rmultinom(1, 20, rep(1, n))[,1]; q <- q / sum(q)
czekanowski_index(p, q)
#> [1] 0.65