composition_stats.inner

composition_stats.inner(x, y)

Calculates 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
xarray_like

a matrix of proportions where rows = compositions and columns = components each composition (row) must add up to unity (see closure())

yarray_like

a matrix of proportions where rows = compositions and columns = components each composition (row) must add up to unity (see closure())

Returns
numpy.ndarray

inner product result

Examples

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