geo_mean {CVXR}R Documentation

Geometric Mean

Description

The (weighted) geometric mean of vector x with optional powers given by p.

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 x_1^{1/n} \cdots x_n^{1/n}.

max_denom

(Optional) The maximum denominator to use in approximating p/sum(p) with w. If w is not an exact representation, increasing max_denom may offer a more accurate representation, at the cost of requiring more convex inequalities to represent the geometric mean. Defaults to 1024.

Details

\left(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 \geq 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.

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)

[Package CVXR version 1.0-14 Index]