var_i: Sample Variance for Integer Values

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/functions.R

Description

Written in C++, this function should always run faster than var for integer vectors. Not valid for non-integer input vectors.

Usage

1
var_i(x)

Arguments

x

Integer vector.

Details

NA

Value

Numeric value.

Note

NA

Author(s)

Dane R. Van Domelen

References

Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.

See Also

NA

Examples

1
2
3
4
5
6
# For integer vectors, var_i is typically much faster than var.
x <- rpois(1000, lambda = 5)
all.equal(var(x), var_i(x))
microbenchmark(var(x),
               var_i(x),
               times = 100)

dvmisc documentation built on Dec. 29, 2017, 3:01 a.m.