blosc2.var#
- blosc2.var(ndarr: NDArray | NDField | C2Array | LazyExpr, axis: int | tuple[int] | None = None, dtype: dtype | str = None, ddof: int = 0, keepdims: bool = False, **kwargs: Any) ndarray | NDArray | int | float | bool #
Return the variance along the specified axis.
The parameters are documented in the
std
.- Returns:
var_along_axis – The variance of the elements along the axis.
- Return type:
np.ndarray or NDArray or scalar
References
Examples
>>> import numpy as np >>> import blosc2 >>> # Create an instance of NDArray with some data >>> array = np.array([[1, 2, 3], [4, 5, 6]]) >>> nd_array = blosc2.asarray(array) >>> # Compute the variance of the entire array >>> var_all = blosc2.var(nd_array) >>> print("Variance of the entire array:", var_all) Variance of the entire array: 2.9166666666666665 >>> # Compute the variance along axis 0 (columns) >>> var_axis0 = blosc2.var(nd_array, axis=0) >>> print("Variance along axis 0:", var_axis0) Variance along axis 0: [2.25 2.25 2.25]