skbio.stats.composition.alr(mat, denominator_idx=0)[source]#

Perform 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 \(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.

matarray_like of shape (n_compositions, n_components)

A matrix of proportions.


The index of the column (2-D matrix) or position (vector) of mat which should be used as the reference composition. Default is 0 which specifies the first column or position.

ndarray of shape (n_compositions, n_components - 1)

Alr-transformed data projected in a non-isometric real space of \(D - 1\) dimensions for a D-parts composition.


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