All problems
Tsallis Entropy
Problem
Return the Tsallis entropy of order q:
S_q = (1 - sum(p_i^q)) / (q - 1)
Assume q != 1 and all probabilities are positive.
Hint
As q approaches 1 the Tsallis entropy converges to the Shannon entropy.
Test cases
case 1
in: [[0.5,0.5],2]
expected: 0.5
case 2
in: [[0.5,0.5],3]
expected: 0.375
case 3
in: [[0.25,0.25,0.25,0.25],2]
expected: 0.75
case 4
in: [[0.5,0.5],0.5]
expected: 0.8284271247461903
Starter codePython
import math
def tsallis_entropy(probs, q):
# Your code here
pass4 test cases · run your code against them in the editor