skbio.stats.composition.
multiplicative_replacement
(mat, delta=None)[source]¶Replace all zeros with small non-zero values
State: Experimental as of 0.4.0.
It uses the multiplicative replacement strategy [R61] , replacing zeros with a small positive \(\delta\) and ensuring that the compositions still add up to 1.
Parameters: | mat: array_like
delta: float, optional
|
---|---|
Returns: | numpy.ndarray, np.float64
|
References
[R61] | (1, 2) J. A. Martin-Fernandez. “Dealing With Zeros and Missing Values in Compositional Data Sets Using Nonparametric Imputation” |
Examples
>>> import numpy as np
>>> from skbio.stats.composition import multiplicative_replacement
>>> X = np.array([[.2,.4,.4, 0],[0,.5,.5,0]])
>>> multiplicative_replacement(X)
array([[ 0.1875, 0.375 , 0.375 , 0.0625],
[ 0.0625, 0.4375, 0.4375, 0.0625]])