pecon.stats.var#
- pecon.stats.var(x, ddof=1)#
Compute the variance of a dataset.
Variance measures the average squared deviation of observations from their mean, indicating the dispersion of the data.
- Parameters:
x (array-like) – One-dimensional sequence of numerical values.
ddof (int, optional) – Delta degrees of freedom. The divisor used is (N - ddof). Use ddof=0 for population variance and ddof=1 for sample variance.
- Returns:
The variance of the data.
- Return type:
float
Notes
The value of ddof must satisfy 0 <= ddof < N, where N is the number of observations. Otherwise, a ValueError is raised.
Examples
>>> from pecon import stats >>> x = [2, 4, 6, 8] >>> var = stats.var(x, ddof=1) >>> print(f"Var = {var}") Var = 6.666666666666667