# -*- coding: utf-8 -*-
"""02_IT.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1lKoR3GtYObIvUomdAIVgzpvhBsOt1W3T
"""

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(100)
y = 1 / np.log2(x)

print(x)
plt.plot(x, y)

x = np.linspace(0, 1, num=51)
y = 1 / np.log2(x)

print(x)
plt.plot(x, y)

def SIC(x):
  return -np.log2(x)

def ENTROPY(x):
  #y = SIC(x)
  return sum([n1 * n2 for n1, n2 in zip(x, SIC(x))])

x = np.array([0.5, 0.5])
SIC(x), ENTROPY(x)

# 12 die (dices); unbalanced; 1 weighs more than rest
# Q: WWSD? 

# c[0] = L > R
# c[1] = L == R
# c[2] = L < R

# 6 v 6
x6 = [0.5, 0.5]
h6 = SIC(x6)
H6 = ENTROPY(x6)
print('6v6', h6, H6)

# 5 v 5 
x5 = [5/12, 2/12, 5/12]
h5 = SIC(x5)
H5 = ENTROPY(x5)
print('5v5', h5, H5)

# 4 v 4 
x4 = [4/12, 4/12, 4/12]
h4 = SIC(x4)
H4 = ENTROPY(x4)
print('4v4', h4, H4)

# 3 v 3
x3 = [3/12, 6/12, 3/12]
h3 = SIC(x3)
H3 = ENTROPY(x3)
print('4v4', h3, H3)


print("MAX ENTROPY: {}; i.e. weigh {}".format(max(H6, H5, H4, H3), 3))

# ROUND 2; HHL v HLL 
R2x3 = [3/8, 2/8, 3/8]
R2h3 = SIC(x3)
R2H3 = ENTROPY(x3)
print('3v3', R2h3, R2H3)

