Instantly share code, notes, and snippets.

# marekyggdrasil/distrib.png

Last active January 27, 2021 13:21
Star You must be signed in to star a gist
A source code for a probability plots for a trustless Mimblewimble transaction aggregator based on scalable BFT https://mareknarozniak.com/2021/01/27/aggrematon/ 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.pyplot as plt def plotDistrib(prop, prob): fig, ax = plt.subplots(1, 1, constrained_layout=True) ax.set_title('cumulative distribution function') ax.set_xlabel('Sybil Byzantine nodes [%]') ax.set_ylabel('p') ax.plot(prop, prob) ax.grid() ax.legend() fig.savefig('distrib.png')
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
 from scipy.stats import hypergeom from plotting import plotDistrib def P(a, b, c, d): return hypergeom.pmf(b, d+c, c, a+b) def Pa(a, b, e, f, n): return sum([P(a, b, x, n-x)*P(x, n-x, e, f) for x in range(n+1)]) def Pac(a_min, c, e, f, n): return sum([Pa(a, c-a, e, f, n) for a in range(a_min, c+1)]) n = 200 nn = n*n c = 36 c_min = 18 prop = [] prob = [] for f in range(1, nn, 1200): x = f/nn print(x) p = Pac(c_min, c, f, nn-f, n) prop.append(x*100.) prob.append(p) plotDistrib(prop, prob)