Fork me on GitHub"

# skbio.stats.composition.ilr

skbio.stats.composition.ilr(mat, basis=None, check=True)

  Performs isometric log ratio transformation.

  State: Experimental as of 0.4.0.

  This function transforms compositions from Aitchison simplex to the real space. The :math: ilr` transform is both an isometry, and an isomorphism defined on the following spaces

  \(ilr: S^D \rightarrow \mathbb{R}^{D-1}\)

  The ilr transformation is defined as follows

  \[ilr(x) = [\langle x, e_1 \rangle_a, \ldots, \langle x, e_{D-1} \rangle_a]\]

  where \([e_1,\ldots,e_{D-1}]\) is an orthonormal basis in the simplex.

  If an orthornormal basis isn’t specified, the J. J. Egozcue orthonormal basis derived from Gram-Schmidt orthogonalization will be used by default.

  Parameters:

    - mat (numpy.ndarray) – a matrix of proportions where rows = compositions and columns = components

    - basis (numpy.ndarray or scipy.sparse.matrix, optional) – orthonormal basis for Aitchison simplex defaults to J.J.Egozcue orthonormal basis.

    - check (bool) – Specifies if the basis is orthonormal.

  Examples

      >>> import numpy as np
      >>> from skbio.stats.composition import ilr
      >>> x = np.array([.1, .3, .4, .2])
      >>> ilr(x)
      array([-0.7768362 , -0.68339802,  0.11704769])

  Notes

  If the basis parameter is specified, it is expected to be a basis in the Aitchison simplex. If there are D-1 elements specified in mat, then the dimensions of the basis needs be D-1 x D, where rows represent basis vectors, and the columns represent proportions.