dpctl.tensor.var(x, axis=None, correction=0.0, keepdims=False)[source]

Calculates the variance of elements in the input array x.

  • x (usm_ndarray) – input array.

  • axis (Optional[int, Tuple[int, ...]]) – axis or axes along which the variances must be computed. If a tuple of unique integers, the variances are computed over multiple axes. If None, the variance is computed over the entire array. Default: None.

  • correction (Optional[float, int]) – degrees of freedom adjustment. The divisor used in calculating the variance is N - correction, where N corresponds to the total number of elements over which the variance is calculated. Default: 0.0.

  • keepdims (Optional[bool]) – if True, the reduced axes (dimensions) are included in the result as singleton dimensions, so that the returned array remains compatible with the input array according to Array Broadcasting rules. Otherwise, if False, the reduced axes are not included in the returned array. Default: False.


an array containing the variances. If the variance was computed over the entire array, a zero-dimensional array is returned.

If x has a real-valued floating-point data type, the returned array will have the same data type as x. If x has a boolean or integral data type, the returned array will have the default floating point data type for the device where input array x is allocated.

Return type: