skbio.stats.composition.closure¶
- skbio.stats.composition.closure(mat)[source]¶
State: Experimental as of 0.4.0. Performs closure to ensure that all elements add up to 1.
- Parameters
mat (array_like) – a matrix of proportions where rows = compositions columns = components
- Returns
A matrix of proportions where all of the values are nonzero and each composition (row) adds up to 1
- Return type
array_like, np.float64
- Raises
ValueError – Raises an error if any values are negative.
ValueError – Raises an error if the matrix has more than 2 dimension.
ValueError – Raises an error if there is a row that has all zeros.
Examples
>>> import numpy as np >>> from skbio.stats.composition import closure >>> X = np.array([[2, 2, 6], [4, 4, 2]]) >>> closure(X) array([[ 0.2, 0.2, 0.6], [ 0.4, 0.4, 0.2]])