skbio.stats.composition.power#

skbio.stats.composition.power(x, a)[source]#

Perform the power operation.

This operation is defined as follows:

\[`x \odot a = C[x_1^a, \ldots, x_D^a]\]

\(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:
xarray_like of shape (n_compositions, n_components)

A matrix of proportions.

afloat

A scalar exponent.

Returns:
ndarray of shape (n_compositions, n_components)

The matrix where all of the values are non-zero and each composition (row) adds up to 1.

Examples

>>> import numpy as np
>>> from skbio.stats.composition import power
>>> x = np.array([.1, .3, .4, .2])
>>> power(x, .1)
array([ 0.23059566,  0.25737316,  0.26488486,  0.24714631])