Skip to main content

Mojo function

variance

variance(src: LayoutTensor[src.dtype, src.layout, src.origin, address_space=src.address_space, element_layout=src.element_layout, layout_int_type=src.layout_int_type, linear_idx_type=src.linear_idx_type, masked=src.masked, alignment=src.alignment], correction: Int = 1) -> Scalar[src.dtype]

Computes the variance value of the elements in a buffer.

variance(x) = sum((x - E(x))^2) / (size - correction)

Args:

  • ​src (LayoutTensor): The buffer.
  • ​correction (Int): Normalize variance by size - correction (Default=1).

Returns:

Scalar: The variance value of the elements in a buffer.

Raises:

May raise on GPU targets when a device error occurs.

variance(src: TileTensor[src.dtype, src.LayoutType, src.origin, address_space=src.address_space, linear_idx_type=src.linear_idx_type, element_shape_types=src.element_shape_types], correction: Int = 1) -> Scalar[src.dtype]

Computes the variance value of the elements in a buffer.

variance(x) = sum((x - E(x))^2) / (size - correction)

Args:

  • ​src (TileTensor): The buffer.
  • ​correction (Int): Normalize variance by size - correction (Default=1).

Returns:

Scalar: The variance value of the elements in a buffer.

Raises:

May raise on GPU targets when a device error occurs.

Was this page helpful?