composition_stats.alr

composition_stats.alr(mat, denominator_idx=0)

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 each composition (row) must add up to unity (see closure())

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
numpy.ndarray

alr-transformed data projected in a non-isometric real space of D-1 dimensions for a D-parts composition

Examples

>>> import numpy as np
>>> from composition_stats import alr
>>> x = np.array([.1, .3, .4, .2])
>>> alr(x)
array([ 1.09861229,  1.38629436,  0.69314718])