composition_stats.ilr¶
- composition_stats.ilr(mat, basis=None, check=True)¶
Performs isometric log ratio transformation.
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 each composition (row) must add up to unity (see closure())
- basis: numpy.ndarray, float, optional
orthonormal basis for Aitchison simplex defaults to J.J.Egozcue orthonormal basis.
- check: bool
Specifies if the basis is orthonormal.
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.
Examples
>>> import numpy as np >>> from composition_stats import ilr >>> x = np.array([.1, .3, .4, .2]) >>> ilr(x) array([-0.7768362 , -0.68339802, 0.11704769])