entropy#

class diffsptk.Entropy(out_format='nat')[source]#

See this page for details.

Parameters:
out_format[‘bit’, ‘nat’, ‘dit’]

Unit of entropy.

forward(p)[source]#

Compute entropy from probability sequence.

Parameters:
pTensor [shape=(…, N)]

Probability sequence.

Returns:
outTensor [shape=(…,)]

Entropy.

Examples

>>> p = diffsptk.step(3) / 4
>>> p
tensor([0.2500, 0.2500, 0.2500, 0.2500])
>>> entropy = diffsptk.Entropy("bit")
>>> h = entropy(p)
>>> h
tensor(2.)
diffsptk.functional.entropy(p, out_format='nat')[source]#

Calculate entropy.

Parameters:
pTensor [shape=(…, N)]

Probability.

out_format[‘bit’, ‘nat’, ‘dit’]

Output format.

Returns:
outTensor [shape=(…,)]

Entropy.

See also

histogram