Computes the variance along the specified dimensions.
Usage
nv_var(operand, dims, drop = TRUE, correction = 1L)
Arguments
- operand
(arrayish)
Operand.
- dims
(integer())
Dimensions to reduce.
- drop
(logical(1))
Whether to drop reduced dimensions.
- correction
(integer(1))
Degrees of freedom correction. Default is 1 (Bessel's correction).
Value
arrayish
Has the same data type as the input.
When drop = TRUE, the reduced dimensions are removed.
When drop = FALSE, the reduced dimensions are set to 1.
Details
Uses Bessel's correction by default (correction = 1), matching R's var().
Set correction = 0 for population variance.
Examples
x <- nv_array(c(1, 2, 3, 4, 5))
nv_var(x, dims = 1L)
#> AnvlArray
#> 2.5000
#> [ CPUf32{} ]