entropy#
- class diffsptk.Entropy(out_format: str | int = 'nat')[source]#
See this page for details.
- Parameters:
- out_format[‘bit’, ‘nat’, ‘dit’]
The unit of the entropy.
- forward(p: Tensor) Tensor [source]#
Compute entropy from probability sequence.
- Parameters:
- pTensor [shape=(…, N)]
The probability sequence.
- Returns:
- outTensor [shape=(…,)]
The 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: Tensor, out_format: str = 'nat') Tensor [source]#
Calculate the entropy of a probability distribution.
- Parameters:
- pTensor [shape=(…, N)]
The probability.
- out_format[‘bit’, ‘nat’, ‘dit’]
The output format.
- Returns:
- outTensor [shape=(…,)]
The entropy.
See also