baybe.utils.numerical.geom_mean

baybe.utils.numerical.geom_mean(arr: ndarray, weights: list[float])[source]

Calculate the (weighted) geometric mean along the second axis of a 2-D array.

Alternative to gmean from scipy that avoids logarithms and division errors.

Parameters:
  • arr (ndarray) – The array containing the values for the mean computation.

  • weights (list[float]) – Weights for the mean computation.

Return type:

ndarray

Returns:

A 1-D array containing the row-wise geometric means of the given array.