skbio.stats.composition.ilr#

skbio.stats.composition.ilr(mat, basis=None, axis=-1, validate=True)[source]#

Perform isometric log ratio (ILR) 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 [1] will be used by default.

Changed in version 0.7.0: The function now works on any dimension in arrays of any number of dimensions.

Parameters:
matarray_like of shape (…, n_components, …)

A matrix of positive proportions.

basisndarray or sparse matrix, optional

Orthonormal basis for Aitchison simplex. Defaults to J. J. Egozcue orthonormal basis.

axisint, optional

Axis along which ILR transformation will be performed. That is, each vector along this axis is considered as a composition. Default is the last axis (-1).

Added in version 0.7.0.

validatebool, default True

Check if i) the matrix is compositional, ii) the basis is orthonormal, 2-dimensional, and the dimensions are matched.

Changed in version 0.7.0: Renamed from check. The old name is kept as an alias but is deprecated.

Returns:
ndarray of shape (…, n_components - 1,…)

ILR-transformed matrix.

See also

ilr_inv

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) \times D\), where rows represent basis vectors, and the columns represent proportions.

References

[1]

Egozcue, J. J., Pawlowsky-Glahn, V., Mateu-Figueras, G., & Barcelo-Vidal, C. (2003). Isometric logratio transformations for compositional data analysis. Mathematical geology, 35(3), 279-300.

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])