import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-colorblind')
x = np.arange(0.00001, 0.99999, 0.00001)
y = -np.log2(x)
fig, ax = plt.subplots(figsize=(16, 8))
ax.plot(x, y)
ax.set_title('$-\log_2$')
ax.set_xlabel('x')
ax.set_xlim(xmin=x[0], xmax=x[-1])
fig.tight_layout();
x = np.arange(0.00001, 0.99999, 0.00001)
y = -x * np.log2(x)
fig, ax = plt.subplots(figsize=(16, 8))
ax.plot(x, y)
ax.set_title('$- x \log_2 (x)$')
ax.set_xlabel('x')
ax.set_xlim(xmin=x[0], xmax=x[-1])
fig.tight_layout();
p = np.arange(0.00001, 0.99999, 0.00001)
H = (-p * np.log2(p) - ((1.0 - p) * np.log2(1.0 - p)))
fig, ax = plt.subplots(figsize=(16, 8))
ax.plot(p, H)
ax.set_title('Entropy')
ax.set_xlabel('p')
ax.set_xlim(xmin=p[0], xmax=p[-1])
fig.tight_layout();