Skip to main content
`Ctrl`+`K`

# skbio.stats.composition.inner

skbio.stats.composition.inner(x, y, validate=True)

  Calculate the Aitchson inner product.

  This inner product is defined as follows:

  \[\langle x, y \rangle_a = \frac{1}{2D} \sum\limits_{i=1}^{D} \sum\limits_{j=1}^{D} \ln\left(\frac{x_i}{x_j}\right) \ln\left(\frac{y_i}{y_j}\right)\]
  Parameters:
    x array_like of shape (n_compositions, n_components)

      A matrix of proportions.

    y array_like of shape (n_compositions, n_components)

      A matrix of proportions.

    validate bool, default True

      Check if the compositions are legitimate.

      Added in version 0.7.0.

  Returns:
    ndarray or scalar of shape (n_compositions, n_compositions)

      Inner product result.

  Examples

      >>> import numpy as np
      >>> from skbio.stats.composition import inner
      >>> x = np.array([.1, .3, .4, .2])
      >>> y = np.array([.2, .4, .2, .2])
      >>> inner(x, y)
      0.2107852473...