geometric_mean
relationalai.semantics.std.aggregates
geometric_mean(*args: AggValue) -> AggregateCompute the geometric mean of values using the exp-log trick.
geometric_mean(x) = (x1 * x2 * ... * xn) ** (1/n) = exp(mean(ln(x))).
Defined for non-negative values: a zero input forces the result to 0.0
(exp(-inf) = 0.0 by IEEE 754); a negative input forces the result to NaN.
Results are floating-point approximations — integer inputs are cast to
Float before aggregation.
Parameters
(*argsAggValue, default:()) - Values to compute the geometric mean over. Can include Distinct wrapper for distinct aggregation.
Returns
Aggregate- AnAggregaterepresenting the geometric mean. Always returnsFloat.
Examples
Compute geometric mean of growth rates:
select(aggregates.geometric_mean(Investment.growth_rate))Compute geometric mean per portfolio:
select(Portfolio.name, aggregates.geometric_mean(Investment.growth_rate).per(Portfolio))