Created
November 18, 2017 10:21
-
-
Save CountChu/a630915c8a6cbfef65680ef6dd64a63f 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
# | |
# Draw the Hoeffding's Inequality with the epsilons = 0.3 and the probability. | |
# | |
from scipy import signal | |
import numpy as np | |
import math | |
def hoeffding (x, epsilon): | |
y = 2.0 * math.exp (-2*epsilon*epsilon*x) | |
return y | |
x = np.arange (0, 20, 0.01) | |
y = [hoeffding (x, 0.3) for x in x] | |
import matplotlib.pyplot as plt | |
plt.xlabel ('N') | |
plt.ylabel ('P') | |
latex1 = r'P\leq2e^{\left( -2\varepsilon ^{2}N\right)}' | |
plt.title (r"Hoeffding's Inequality: $ %s $" % latex1) | |
latext2 = r'\varepsilon' | |
plt.plot (x, y, label='$%s$ = 0.3' % latext2) | |
x2 = 10 | |
y2 = hoeffding (10, 0.3) | |
#plt.plot ([0, 10], [y2, y2], label='y = %f' % y2) | |
plt.axhline (y = y2, color='grey', linestyle='--') | |
plt.axvline (x = x2, color='grey', linestyle='--') | |
plt.scatter (x2, y2, color='red', label='x = %d, y = %f' % (x2, y2)) | |
plt.legend () | |
plt.show () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment