Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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')

This comment has been minimized.

Copy link

@Wuttichaiza Wuttichaiza commented Oct 6, 2018

Wuttichai Chauymouang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.