composition_stats.alr_inv¶
- composition_stats.alr_inv(mat, denominator_idx=0)¶
Performs inverse additive log ratio transform.
This function transforms compositions from the non-isometric real space of alrs to Aitchison geometry.
\(alr^{-1}: \mathbb{R}^{D-1} \rightarrow S^D\)
The inverse alr transformation is defined as follows
\[alr^{-1}(x) = C[exp([y_1, y_2, ..., y_{D-1}, 0])]\]where \(C[x]\) is the closure operation defined as
\[C[x] = \left[\frac{x_1}{\sum_{i=1}^{D} x_i},\ldots, \frac{x_D}{\sum_{i=1}^{D} x_i} \right]\]for some \(D\) dimensional real vector \(x\) and \(D\) is the number of components for every composition.
- Parameters
- mat: numpy.ndarray
a matrix of alr-transformed data
- denominator_idx: int
the index of the column (2D-composition) or position (1D-composition) of the output where the common denominator should be placed. By default denominator_idx=0 to specify the first column or position.
- Returns
- numpy.ndarray
Inverse alr transformed matrix or vector where rows sum to 1.
Examples
>>> import numpy as np >>> from composition_stats import alr, alr_inv >>> x = np.array([.1, .3, .4, .2]) >>> alr_inv(alr(x)) array([ 0.1, 0.3, 0.4, 0.2])