Created
July 12, 2019 01:51
-
-
Save lockdef/6f0c259e4d4fec2ce0f5e46fdb09aad7 to your computer and use it in GitHub Desktop.
平均エントロピーの関数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def avg_entropy(num_arr): | |
num_arr = list(map(lambda x: x * math.log2(x), num_arr)) | |
return -sum(num_arr) | |
if __name__=='__main__': | |
input_num = [0.05, 0.25, 0.70] | |
output = avg_entropy(input_num) | |
print('output :', output) | |
# output : 1.0762976257251988 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment