Skip to main content

function

variance

variance(src: Buffer[type, size, address_space], mean_value: SIMD[type, 1], correction: Int = 1) -> SIMD[$0, 1]

Given a mean, computes the variance of elements in a buffer.

The mean value is used to avoid a second pass over the data:

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

Args:

  • src (Buffer[type, size, address_space]): The buffer.
  • mean_value (SIMD[type, 1]): The mean value of the buffer.
  • correction (Int): Normalize variance by size - correction.

Returns:

The variance value of the elements in a buffer.

variance(src: Buffer[type, size, address_space], correction: Int = 1) -> SIMD[$0, 1]

Computes the variance value of the elements in a buffer.

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

Args:

  • src (Buffer[type, size, address_space]): The buffer.
  • correction (Int): Normalize variance by size - correction (Default=1).

Returns:

The variance value of the elements in a buffer.