GeoMean-class function

The GeoMean class.

The GeoMean class.

This class represents the (weighted) geometric mean of vector xx with optional powers given by pp. class

GeoMean(x, p = NA_real_, max_denom = 1024) ## S4 method for signature 'GeoMean' to_numeric(object, values) ## S4 method for signature 'GeoMean' .domain(object) ## S4 method for signature 'GeoMean' .grad(object, values) ## S4 method for signature 'GeoMean' name(x) ## S4 method for signature 'GeoMean' dim_from_args(object) ## S4 method for signature 'GeoMean' sign_from_args(object) ## S4 method for signature 'GeoMean' is_atom_convex(object) ## S4 method for signature 'GeoMean' is_atom_concave(object) ## S4 method for signature 'GeoMean' is_atom_log_log_convex(object) ## S4 method for signature 'GeoMean' is_atom_log_log_concave(object) ## S4 method for signature 'GeoMean' is_incr(object, idx) ## S4 method for signature 'GeoMean' is_decr(object, idx) ## S4 method for signature 'GeoMean' get_data(object) ## S4 method for signature 'GeoMean' copy(object, args = NULL, id_objects = list())

Arguments

  • x: An Expression or numeric vector.
  • p: (Optional) A vector of weights for the weighted geometric mean. The default is a vector of ones, giving the unweighted geometric mean x11/nxn1/nx_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.
  • object: A GeoMean object.
  • values: A list of numeric values for the arguments
  • idx: An index into the atom.
  • args: An optional list that contains the arguments to reconstruct the atom. Default is to use current arguments of the atom.
  • id_objects: Currently unused.

Details

(x1p1xnpn)11Tp \left(x_1^{p_1} \cdots x_n^{p_n} \right)^{\frac{1}{\mathbf{1}^Tp}}

The geometric mean includes an implicit constraint that xi0x_i \geq 0 whenever pi>0p_i > 0. If pi=0,xip_i = 0, x_i will be unconstrained. The only exception to this rule occurs when pp has exactly one nonzero element, say pip_i, in which case GeoMean(x,p) is equivalent to xix_i (without the nonnegativity constraint). A specific case of this is when xR1x \in \mathbf{R}^1.

Methods (by generic)

  • to_numeric(GeoMean): The (weighted) geometric mean of the elements of x.
  • .domain(GeoMean): Returns constraints describing the domain of the node
  • .grad(GeoMean): Gives the (sub/super)gradient of the atom w.r.t. each variable
  • name(GeoMean): The name and arguments of the atom.
  • dim_from_args(GeoMean): The atom is a scalar.
  • sign_from_args(GeoMean): The atom is non-negative.
  • is_atom_convex(GeoMean): The atom is not convex.
  • is_atom_concave(GeoMean): The atom is concave.
  • is_atom_log_log_convex(GeoMean): Is the atom log-log convex?
  • is_atom_log_log_concave(GeoMean): Is the atom log-log concave?
  • is_incr(GeoMean): The atom is weakly increasing in every argument.
  • is_decr(GeoMean): The atom is not weakly decreasing in any argument.
  • get_data(GeoMean): Returns list(w, dyadic completion, tree of dyads).
  • copy(GeoMean): Returns a shallow copy of the GeoMean atom

Slots

  • x: An Expression or numeric vector.
  • p: (Optional) A vector of weights for the weighted geometric mean. The default is a vector of ones, giving the unweighted geometric mean x11/nxn1/nx_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.
  • w: (Internal) A list of bigq objects that represent a rational approximation of p/sum(p).
  • approx_error: (Internal) The error in approximating p/sum(p) with w, given by p/1Tpw\|p/\mathbf{1}^Tp - w\|_{\infty}.
  • Maintainer: Anqi Fu
  • License: Apache License 2.0 | file LICENSE
  • Last published: 2024-11-07