cov_i: Sample Covariance for Integer Vectors

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

Written in C++, this function should always run faster than cov for integer vectors. Will give incorrect result for non-integer vectors, and does not check that x and y are same length or that they contain no missing values.

Usage

1
cov_i(x, y)

Arguments

x, y

Integer vector.

Value

Numeric value.

Examples

1
2
3
4
5
# For integer vectors, cov_i is typically much faster than cov.
x <- rpois(1000, lambda = 5)
y <- rpois(1000, lambda = 5)
all.equal(cov(x, y), cov_i(x, y))
benchmark(cov(x, y), cov_i(x, y), replications = 5000)

dvmisc documentation built on May 2, 2019, 5:51 p.m.

Related to cov_i in dvmisc...