skbio.stats.composition.ilr#
- skbio.stats.composition.ilr(mat, basis=None, check=True)[source]#
Perform isometric log ratio transformation.
This function transforms compositions from Aitchison simplex to the real space. The \(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:
- matarray_like of shape (n_compositions, n_components)
A matrix of proportions.
- basisndarray or sparse matrix, optional
Orthonormal basis for Aitchison simplex. Defaults to J. J. Egozcue orthonormal basis.
- checkbool
Check to see if basis is orthonormal.
- Returns:
- ndarray of shape (n_compositions, n_components - 1)
Ilr-transformed matrix.
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 inmat
, then the dimensions of the basis needs be \((D-1) \times D\), where rows represent basis vectors, and the columns represent proportions.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])