Extract common scope code snippet

This commit is contained in:
danielsanchezq 2023-06-27 13:12:06 +02:00
parent 7528506b21
commit 18c8407edb
1 changed files with 6 additions and 10 deletions

View File

@ -30,12 +30,13 @@ def compute_optimal_number_of_committees_and_committee_size(
number_of_committees = 2 * odd_committee + 1
committee_size = number_of_nodes // number_of_committees
remainder = number_of_nodes % number_of_committees
committee_size_probability = binom.cdf(
math.floor(adversaries_threshold_per_committee * committee_size),
committee_size,
network_adversary_threshold
)
if 0 < remainder:
committee_size_probability = binom.cdf(
math.floor(adversaries_threshold_per_committee * committee_size),
committee_size,
network_adversary_threshold
)
committee_size_plus_one_probability = binom.cdf(
math.floor(adversaries_threshold_per_committee * (committee_size + 1)),
committee_size + 1,
@ -43,11 +44,6 @@ def compute_optimal_number_of_committees_and_committee_size(
)
current_probability = 1 - committee_size_probability ** (number_of_committees - remainder) * committee_size_plus_one_probability ** remainder
else:
committee_size_probability = binom.cdf(
math.floor(adversaries_threshold_per_committee * committee_size),
committee_size,
network_adversary_threshold
)
current_probability = 1 - committee_size_probability ** number_of_committees
# return number of committees, K_1, committee size, n_1, number of committees
# with size n_1+1, r_1 and prob. of failure, Prob_1.