IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

variance

variance(src: LayoutTensor[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:

Returns:

Scalar[src.dtype]: The variance value of the elements in a buffer.

Raises:

May raise on GPU targets when a device error occurs.

variance(src: TileTensor[address_space=src.address_space, linear_idx_type=src.linear_idx_type, element_size=src.element_size], 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:

Returns:

Scalar[src.dtype]: The variance value of the elements in a buffer.

Raises:

May raise on GPU targets when a device error occurs.