var_n: Sample Variance for Numeric Values

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

Written in C++, this function should always run faster than var for numeric vectors. For integer vectors, var_i should run even faster.

Usage

1
var_n(x)

Arguments

x

Numeric vector.

Value

Numeric value.

Examples

1
2
3
4
5
6
7
8
9
# In general, var_n is much faster than var.
x <- rnorm(1000)
all.equal(var(x), var_n(x))
benchmark(var(x), var_n(x), replications = 1000)

# For integer vectors, var_i should be even faster.
x <- rpois(1000, lambda = 5)
all.equal(var(x), var_i(x))
benchmark(var(x), var_n(x), var_i(x), replications = 1000)

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

Related to var_n in dvmisc...