-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdist.py
More file actions
executable file
·36 lines (29 loc) · 997 Bytes
/
dist.py
File metadata and controls
executable file
·36 lines (29 loc) · 997 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
34
35
36
# Testing distribution functions
from random import normalvariate, expovariate
def dist(rep, sum, max, zero):
if rep < 0:
rep = 0
if max < rep:
max = rep
if rep == 0:
zero += 1
sum += rep
return sum, max, zero
sum1 = max1 = zero1 = 0
sum2 = max2 = zero2 = 0
sum3 = max3 = zero3 = 0
i = 0
for x in range(0, 66548):
d1 = round(normalvariate(-1, 3))
sum1, max1, zero1 = dist(d1, sum1, max1, zero1)
d2 = round(normalvariate(-3, 4))
sum2, max2, zero2 = dist(d2, sum2, max2, zero2)
d3 = round(expovariate(7)*10)
sum3, max3, zero3 = dist(d3, sum3, max3, zero3)
# print("%s, %s, %s" % (i, d1, d2))
i += 1
print("i = " + str(i))
print("Sum: %s %s %s" % (sum1, sum2, sum3))
print("Max: %s %s %s " % (max1, max2, max3))
print("Zero: %s %s %s" % (zero1, zero2, zero3))
print("Non-Zero: %s %s %s" % (i-zero1, i-zero2, i-zero3))