Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
block probability
import matplotlib
import numpy.random
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
#https://www.reddit.com/r/Bitcoin/comments/4gp28d/how_to_avoid_getting_ripped_off_in_large_btc/
#https://en.bitcoin.it/wiki/Confirmation
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'$\%$'
else:
return s + '%'
plt.clf()
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.grid(1)
plt.gca().yaxis.set_major_formatter(FuncFormatter(to_percent))
#plt.show()
plt.savefig('block-cumulative-interval.png' if cumulative else 'block-interval.png')
@Wuttichaiza

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.