dist¶
- dist(mat: ndarray, axis: int = None, mode: str = 'sem', ddof: int = 0, where: ndarray = None, keepdims: bool = False, xp=None) tuple[float, float] | list[float, float] | ndarray[2, float][source][source]¶
Calculate the mean and standard deviation of a matrix.
This function calculates the mean and standard deviation of a matrix along a given axis. If a mask is provided, the mean and standard deviation are calculated only for the elements of the matrix that are not masked.
- Parameters:
mat (
np.ndarray) – Matrix to calculate mean and standard deviation of.axis (
int) – Axis of matrix to calculate mean and standard deviation along.mode (
str) – Mode of standard deviation to calculate. Can be ‘sem’ for standard error of the mean or ‘std’ for standard deviation.where (
np.ndarray) – Mask of elements to include in mean and standard deviation calculation.ddof (int)
keepdims (bool)
- Returns:
Tuple containing the mean and standard deviation of the matrix.
- Return type:
Doubles
Examples
>>> import numpy as np >>> mat = np.arange(24).reshape(4,6) >>> dist(mat, 0)[1] array([3.35410197, 3.35410197, 3.35410197, 3.35410197, 3.35410197, 3.35410197]) >>> dist(mat, 0, mode='std')[1] array([6.70820393, 6.70820393, 6.70820393, 6.70820393, 6.70820393, 6.70820393])