Geometric Mean
The (weighted) geometric mean of vector x with optional powers given by p.
geo_mean(x, p = NA_real_, max_denom = 1024)
x |
An Expression or vector. |
p |
(Optional) A vector of weights for the weighted geometric mean. Defaults to a vector of ones, giving the unweighted geometric mean x_1^{1/n} \cdots x_n^{1/n}. |
max_denom |
(Optional) The maximum denominator to use in approximating |
≤ft(x_1^{p_1} \cdots x_n^{p_n} \right)^{\frac{1}{\mathbf{1}^Tp}}
The geometric mean includes an implicit constraint that x_i ≥q 0 whenever p_i > 0. If p_i = 0, x_i will be unconstrained.
The only exception to this rule occurs when p has exactly one nonzero element, say p_i, in which case geo_mean(x,p)
is equivalent to x_i (without the nonnegativity constraint).
A specific case of this is when x \in \mathbf{R}^1.
An Expression representing the geometric mean of the input.
x <- Variable(2) cost <- geo_mean(x) prob <- Problem(Maximize(cost), list(sum(x) <= 1)) result <- solve(prob) result$value result$getValue(x) ## Not run: x <- Variable(5) p <- c(0.07, 0.12, 0.23, 0.19, 0.39) prob <- Problem(Maximize(geo_mean(x,p)), list(p_norm(x) <= 1)) result <- solve(prob) result$value result$getValue(x) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.