Skip to content

Instantly share code, notes, and snippets.

Created May 15, 2016 02:55
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chris-belcher/647ccff5efc34511979767184153c3da to your computer and use it in GitHub Desktop.
block probability
import matplotlib
import numpy.random
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
cumulative = True
def to_percent(y, position):
# Ignore the passed in position. This has the effect of scaling the default
# tick locations.
s = str(100 * y)
# The percent symbol needs escaping in latex
if matplotlib.rcParams['text.usetex'] is True:
return s + r'$\%$'
return s + '%'
plt.hist(numpy.random.exponential(10, 1e7), bins=100, normed=True, cumulative=cumulative)
plt.xlim(0, 80)
plt.xlabel('Minutes waited' if cumulative else 'Minutes between blocks')
plt.ylabel('Probability of block being found' if cumulative else 'Probability')
plt.title('Block waiting time' if cumulative else 'Time between blocks')
plt.savefig('block-cumulative-interval.png' if cumulative else 'block-interval.png')
Copy link

Wuttichai Chauymouang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment