var(input: Tensor, dim: _int | Sequence[_int] | None = None, unbiased: _bool | None = None, keepdim: _bool = False, correction: _int | _float | None = None)Implementing kernel
C++ engine symbols that back this Python API.Compute the variance along dim.
The sum of squared deviations from the mean, divided by
for n reduced elements and correction
. correction=1 (the default) is Bessel's unbiased sample
variance; correction=0 the population variance.
Parameters
inputTensorInput tensor.
dimint or sequence of int= NoneDimension(s) to reduce.
None reduces every element. A
dimension named twice is refused.unbiasedbool= NoneTrue is correction=1, False correction=0; it
overrides correction when given. A bool in the place of
dim — var(x, False) — is read as this.keepdimbool= FalseWhether to retain reduced dims with size 1.
correctionint or float= NoneDegrees-of-freedom correction . Default
1.Returns
TensorReduced floating-point tensor.
Raises
ValueErrorIf
dim names one dimension twice.Notes
With the divisor is 0: a slice with no spread gives
nan and one with spread inf — so var of a single element is
nan under the default correction, as is any empty reduction.
Examples
>>> import lucid
>>> x = lucid.tensor([[1.0, 2.0, 3.0, 4.0], [2.0, 4.0, 6.0, 8.0]])
>>> lucid.var(x, 1)
tensor([1.667, 6.667])
>>> lucid.var(x, 1, False, True)
tensor([[1.25], [5.]])