skbio.stats.composition.
closure
(mat)[source]¶State: Experimental as of 0.4.0. Performs closure to ensure that all elements add up to 1.
mat (array_like) – a matrix of proportions where rows = compositions columns = components
A matrix of proportions where all of the values are nonzero and each composition (row) adds up to 1
array_like, np.float64
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]])