baybe.utils.numerical.geom_mean¶
- baybe.utils.numerical.geom_mean(arr: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], weights: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])[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 (
Union
[_Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[bool
|int
|float
|complex
|str
|bytes
]]) – The array containing the values for the mean computation.weights (
Union
[_Buffer
,_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[bool
|int
|float
|complex
|str
|bytes
]]) – Weights for the mean computation.
- Return type:
- Returns:
A 1-D array containing the row-wise geometric means of the given array.