geo_mean {CVXR} | R Documentation |
Geometric Mean
Description
The (weighted) geometric mean of vector with optional powers given by
.
Usage
geo_mean(x, p = NA_real_, max_denom = 1024)
Arguments
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 |
max_denom |
(Optional) The maximum denominator to use in approximating |
Details
The geometric mean includes an implicit constraint that whenever
. If
will be unconstrained.
The only exception to this rule occurs when
has exactly one nonzero element, say
, in which case
geo_mean(x,p)
is equivalent to (without the nonnegativity constraint).
A specific case of this is when
.
Value
An Expression representing the geometric mean of the input.
Examples
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)