Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement