-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandnumTEST.py
More file actions
113 lines (84 loc) · 2.04 KB
/
randnumTEST.py
File metadata and controls
113 lines (84 loc) · 2.04 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# -*- coding: utf-8 -*-
"""
Created on Tue May 29 02:53:13 2018
@author: Derek Christensen
"""
from __future__ import print_function
from __future__ import division
#import random
import math
def arrgetrand(arrrate):
arrexporand = -math.log(1.0 - arrlcg()) / arrrate
return (arrexporand)
def arrlcg():
a = 100801
c = 103319
m = 193723
global curarrseed
curarrseed = (a*curarrseed + c) % m
arrlcgnum = curarrseed / m
return(arrlcgnum)
def depgetrand(deprate):
depexporand = -math.log(1.0 - deplcg()) / deprate
return (depexporand)
def deplcg():
a = 7000313
c = 0
m = 9004091
global curdepseed
curdepseed = (a*curdepseed + c) % m
deplcgnum = curdepseed / m
return(deplcgnum)
######
# main
######
arrtimes = []
deptimes = []
reparr = []
repdep = []
origarrseed = 50001
origdepseed = 94907
global curarrseed
global curdepseed
curarrseed = 50001
curdepseed = 94907
numreps = 3
for rep in range(0,numreps):
sumarr = 0
sumdep = 0
avgarr = 0
avgdep = 0
arrmean = 3
arrrate = 1/arrmean
depmean = 2
deprate = 1/depmean
print('arrivals')
arrnumreps = 10
for i in range(arrnumreps):
arrexporand = arrgetrand(arrrate)
print(arrexporand)
arrtimes.append(arrexporand)
sumarr += arrexporand
print('departures')
depnumreps = 10
for j in range(depnumreps):
depexporand = depgetrand(deprate)
print(depexporand)
deptimes.append(depexporand)
sumdep += depexporand
avgarr = sumarr / arrnumreps
avgdep = sumdep / depnumreps
reparr.append(avgarr)
repdep.append(avgdep)
print()
print('arrtimes =', arrtimes)
print()
print()
print('deptimes =', deptimes)
print()
print()
print('reparr =', reparr)
print()
print()
print('repdep =', repdep)
print()