@SureshPatil/

HospitableNutritiousDistributedcomputing

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import math

def AttackerSuccessProbability(q, z):
  p = 1.0 - q
  lamb = z * (q / p)
  sum = 1.0
  i = 0
  k = 0
  for k in range (z + 1):
    poisson = pow(math.e, -lamb);
    for i in range(1, k + 1):
      poisson *= lamb / i
    sum -= poisson * (1 - pow(q / p, z - k))
  return sum


for rando in range(2, 5):
  print('q =', rando*0.05)
  for z in range(1, 10):
    result = AttackerSuccessProbability(rando * 0.05, z)
    print('P =', result, 'z =', z)
  print('-------------------------')

# for rando in range (2, 10):
#   for z in range(0, 400):
#     result = AttackerSuccessProbability(rando * 0.05, z)
#     if result < 0.001:
#       print('q =', rando * 0.05, 'z =', z)
#       break