-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomnumber.py
More file actions
56 lines (40 loc) · 1.1 KB
/
randomnumber.py
File metadata and controls
56 lines (40 loc) · 1.1 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
import random
import matplotlib.pyplot as plt
from plotly.graph_objs import Bar, Layout
from plotly import offline
results = []
x = []
for n in range (1,100):
results.append(random.randint(0,8))
#results.append ( int((norm.rvs(size=1,loc=1,scale=0.15)[0]*7).round(0)))
x.append(n)
# fig, ax = plt.subplots()
# plt.plot(x,results, label='Cummulative actual cases total')
# #plt.show()
frequencies = []
# print (results)
m = max(results)+1
for value in range(1,m):
freq = results.count(value)
frequencies.append(freq)
#print (frequencies)
cumm=[]
t=0
# calculate cummulative values
for freq in frequencies:
t+=freq
cumm.append(t)
#visualize in the browser
x_values = list (range(1,m))
data = [Bar (x=x_values, y = frequencies)]
x_axis_config = {'title':'Result'}
y_axis_config = {'title':'Frequency'}
TITLE = "x"
my_layout = Layout (title=TITLE,
xaxis = x_axis_config, yaxis=y_axis_config)
offline.plot ({'data':data, 'layout': my_layout})
# plot on the console
plt.xlabel("# of dice thrown ")
plt.ylabel("frequencies")
plt.bar(x_values, frequencies)
plt.show