skbio.stats.composition.alr¶
- skbio.stats.composition.alr(mat, denominator_idx=0)[source]¶
State: Experimental as of 0.5.5. Performs additive log ratio transformation.
This function transforms compositions from a D-part Aitchison simplex to a non-isometric real space of D-1 dimensions. The argument denominator_col defines the index of the column used as the common denominator. The :math: alr transformed data are amenable to multivariate analysis as long as statistics don’t involve distances.
\(alr: S^D \rightarrow \mathbb{R}^{D-1}\)
The alr transformation is defined as follows
\[alr(x) = \left[ \ln \frac{x_1}{x_D}, \ldots, \ln \frac{x_{D-1}}{x_D} \right]\]where \(D\) is the index of the part used as common denominator.
- Parameters
mat (numpy.ndarray) – a matrix of proportions where rows = compositions and columns = components
denominator_idx (int) – the index of the column (2D-matrix) or position (vector) of mat which should be used as the reference composition. By default denominator_idx=0 to specify the first column or position.
- Returns
alr-transformed data projected in a non-isometric real space of D-1 dimensions for a D-parts composition
- Return type
Examples
>>> import numpy as np >>> from skbio.stats.composition import alr >>> x = np.array([.1, .3, .4, .2]) >>> alr(x) array([ 1.09861229, 1.38629436, 0.69314718])