Instantly share code, notes, and snippets.

# chris-belcher/block-probability.py

Created May 15, 2016 02:55
Show Gist options
• Save chris-belcher/647ccff5efc34511979767184153c3da to your computer and use it in GitHub Desktop.
block probability
This file contains 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
 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 commented Oct 6, 2018

Wuttichai Chauymouang