skbio.stats.composition.clr_inv#
- skbio.stats.composition.clr_inv(mat, axis=-1, validate=True)[source]#
Perform inverse centre log ratio (CLR) transformation.
This function transforms compositions from the real space to Aitchison geometry. The \(clr^{-1}\) transform is both an isometry, and an isomorphism defined on the following spaces:
\[clr^{-1}: U \rightarrow S^D\]where \(U= \{x :\sum\limits_{i=1}^D x = 0 \; \forall x \in \mathbb{R}^D\}\)
This transformation is defined as follows:
\[clr^{-1}(x) = C[\exp( x_1, \ldots, x_D)]\]Changed in version 0.7.0: The function now works on any dimension in arrays of any number of dimensions.
- Parameters:
- matarray_like of shape (…, n_components, …)
A matrix of CLR-transformed data.
- axisint, optional
Axis along which inverse CLR transformation will be performed. Each vector on this axis is considered as a CLR-transformed composition. Default is the last axis (-1).
Added in version 0.7.0.
- validate: bool, optional
Check if the matrix has been centered at 0. Violation will result in a warning rather than an error, for backward compatibility. Defaults to True.
Added in version 0.7.0.
- Returns:
- ndarray of shape (…, n_components, …)
Inverse CLR-transformed matrix.
See also
Notes
The output of
clr_inv
is guaranteed to have each composition sum to 1. But this property isn’t required for the input forclr
. Therefore,clr_inv
does not completely invertclr
. Instead,clr_inv(clr(mat))
andclosure(mat)
are equal.Examples
>>> import numpy as np >>> from skbio.stats.composition import clr_inv >>> x = np.array([.1, .3, .4, .2]) >>> clr_inv(x) array([ 0.21383822, 0.26118259, 0.28865141, 0.23632778])