Skip to content

Instantly share code, notes, and snippets.

@marekyggdrasil
Last active January 27, 2021 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marekyggdrasil/9fd3a85ade53c3e0965241ec7f4cb330 to your computer and use it in GitHub Desktop.
Save marekyggdrasil/9fd3a85ade53c3e0965241ec7f4cb330 to your computer and use it in GitHub Desktop.
A source code for a probability plots for a trustless Mimblewimble transaction aggregator based on scalable BFT https://mareknarozniak.com/2021/01/27/aggrematon/
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')
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment