Tensor.variance
- Tensor.variance()
Compute the variance of a univariate numerical discrete distribution.
- Raises:
pyagrum.ArgumentError – If the tensor is not a 1-dimensional distribution (sum != 1) or if the variable is not numerical.
- Returns:
the variance of the distribution
- Return type:
float
Example
import pyagrum as gum
x = gum.fastVariable("x{1|2|4}")
p = gum.Tensor().add(x).fillWith([0.2, 0.5, 0.3])
round(p.variance(), 4)
# 1.24
Class