-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht.throughput.py
More file actions
33 lines (25 loc) · 872 Bytes
/
t.throughput.py
File metadata and controls
33 lines (25 loc) · 872 Bytes
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
32
33
# simulation of throughput
import math
from random import random
def poisson(lam):
L, k, p = math.exp(-lam), 1, random()
while p > L:
k = k + 1
p = p * random()
return k -1
def throughput_sec(lam): # lam = mean of times per sec
return poisson(lam)
def throughput_min(lam): # lam = mean of times per min
return sum([throughput_sec(lam/60) for i in range(60)])
def throughput_hour(lam): # lam = mean of times per hour
return sum([throughput_sec(lam/3600) for i in range(3600)])
print("throughput of hours")
for i in range(50):
print(throughput_hour(126.1))
print("throughput of mins")
for i in range(50):
print(throughput_min(2.1)) # 126.1 / 60
print("throughput of sec")
for i in range(50):
print(throughput_sec(0.035)) # 126.1 /3600
input("press enter to leave")