Skip to main content

ClikaRT::ops::var

function

var()

Tensor var(
    Tensor x,
    ClikaRT::Span<const std::int64_t> dims = {},
    int64_t correction = 1,
    bool keepdim = false
)

Variance of x over dims, with Bessel correction.

out=1nci(xixˉ)2\mathrm{out} = \tfrac{1}{n - c}\sum_{i}\,(x_i - \bar{x})^2

correction is the c above: 1 (the default) gives the sample variance, 0 the population form.

Parameters

  • x: the input tensor; float dtype.
  • dims: axes to reduce; empty = all axes.
  • correction: degrees-of-freedom adjustment; default 1.
  • keepdim: keep reduced axes as size-1 dims; default false.

Returns: the variances; shape = x minus dims.

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) on an out-of-range dims entry.

Declared in ClikaRT/compute/ops.h, line 4471