Last active
September 8, 2022 23:57
-
-
Save gakonst/f7756debc09a75ce6c54eb526be14e52 to your computer and use it in GitHub Desktop.
Probability of a malicious validator controlling majority of a 6125-size committee
This file contains hidden or 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 math | |
def choose(n, k): return math.factorial(n) // math.factorial(k) // math.factorial(n-k) | |
def prob(n, k, p): return math.exp(math.log(p) * k + math.log(1-p) * (n-k) + math.log(choose(n, k))) | |
def probge(n, k, p): return sum([prob(n, i, p) for i in range(k, n+1)]) | |
committee = 6125 | |
half = committee / 2 | |
for p in [0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51]: | |
print(probge(committee, half, p)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don