In [20]:
%matplotlib inline
%config InlineBackend.figure_format='retina'
In [31]:
import matplotlib.pyplot as plt
import numpy as np
p0s = np.arange(0, 1, 0.01)
def entropy (*ps):
return - sum(ps * np.log2(ps))
etas = map(lambda p0: entropy(p0, 1-p0), p0s)
In [37]:
plt.plot(p0s, etas)
plt.ylim(-0.5, 1.5)
plt.title("Entropy Vs. P_0 in a two-part system");
In [35]:
entropy(0.5, 0.5)
Out[35]:
In [ ]:
# Information Gain
0.5 * entropy(0.5, 0.5) + 0.5 * entropy(1)
In [ ]: