---
title: "ClikaRT::ops::var"
sidebar_label: "var"
description: "Variance of input over dims, with Bessel correction. \\[ \\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 popula…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## var() {#var}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`var`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dims` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `correction` `=` `1`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `keepdim` `=` `false`<br />
)

</div>

Variance of `input` over `dims`, with Bessel correction.

$$
\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**

- `input`: 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 = `input` minus `dims`.

**Throws**

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

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 4609

</div>
