-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathriodistribution.py
161 lines (120 loc) · 4.38 KB
/
riodistribution.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# Written 18/11/2016 by dh4gan
# This script runs both the Q and delta questions repeatedly
# to explore all possible answers, and then compute the resulting R distribution
import rio2definitions as d
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
import matplotlib.mlab as mlab
title = '\t\t\t RIO SCALE 2.0 Distribution \n\t\t\t -------------------------'
print title
print 'Computing all possible values of Q'
print '-------------------------'
Qvalues = []
whereanswers = [1,2,3,4,5]
commanswers = [1,2,3,4]
awareanswers = [1,2,3,4]
for w in whereanswers:
for c in commanswers:
for a in awareanswers:
Q =d.ask_all_Q_questions(text=False,whereanswer=w,commanswer=c,awareanswer=a)
Qvalues.append(Q)
print 'Computing all possible values of delta'
print '-------------------------'
Avalues = []
Bvalues = []
Cvalues = []
Jvalues = []
deltavalues = []
certaintyanswers=personanswers=instrumentanswers=hoaxanswers=["y","n"]
amenableanswers=buildersanswers=[0,1,2,3]
communityanswers = range(10)
for cert in certaintyanswers:
for am in amenableanswers:
for per in personanswers:
for inst in instrumentanswers:
for build in buildersanswers:
for h in hoaxanswers:
for comm in communityanswers:
A,B,C,J,delta=d.ask_all_delta_questions(text=False,certaintyanswer=cert,amenableanswer=am,personanswer=per,instrumentanswer=inst,buildersanswer=build,hoaxanswer=h,communityanswer=comm)
Avalues.append(A)
Bvalues.append(B)
Cvalues.append(C)
Jvalues.append(J)
deltavalues.append(delta)
print A,B,C,J,delta
print "Computing all possible Rio values"
print '-------------------------'
Riovalues = []
for Q in Qvalues:
for delta in deltavalues:
Rio = Q*delta
Riovalues.append(Rio)
mean = np.mean(np.array(Qvalues))
median = np.median(np.array(Qvalues))
stdev = np.std(np.array(Qvalues))
print "Q Statistics:"
print "Maximum: ",np.amax(Qvalues)
print "Minimum: ", np.amin(Qvalues)
print "Mean: ",mean
print "Median: ", median
print "Stdev: ",stdev
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.hist(Qvalues, range=[1,10],normed=True,bins=10)
ax1.set_xlabel("$Q$", fontsize=22)
ax1.set_xlim(0,11)
ax1.set_ylabel("Relative Frequency",fontsize=22)
fig1.savefig('plots/Q_distribution.png')
mean = np.mean(np.array(Jvalues))
median = np.median(np.array(Jvalues))
stdev = np.std(np.array(Jvalues))
print '-------------------------'
print "J Statistics:"
print "Maximum: ",np.amax(Jvalues)
print "Minimum: ", np.amin(Jvalues)
print "Mean: ",mean
print "Median: ", median
print "Stdev: ",stdev
mean = np.mean(np.array(deltavalues))
median = np.median(np.array(deltavalues))
stdev = np.std(np.array(deltavalues))
fig2 = plt.figure()
ax2 = fig2.add_subplot(111)
ax2.hist(Jvalues, range=[0,10],normed=True,log=True,bins=100)
ax2.set_xlabel("$J$", fontsize=22)
ax2.set_xlim(0,11)
ax2.set_ylabel("Relative Frequency",fontsize=22)
fig2.savefig('plots/J_distribution.png')
print '-------------------------'
print "Delta Statistics:"
print "Maximum: ",np.amax(deltavalues)
print "Minimum: ", np.amin(deltavalues)
print "Mean: ",mean
print "Median: ", median
print "Stdev: ",stdev
fig3 = plt.figure()
ax3 = fig3.add_subplot(111)
ax3.hist(deltavalues, range=[0,1], normed=True, log=True, bins=np.logspace(-5,0,100))
ax3.set_xscale('log')
ax3.set_xlabel("$\delta$", fontsize=22)
ax3.set_ylabel("Relative Frequency",fontsize=22)
fig3.savefig('plots/delta_distribution.png')
mean = np.mean(np.array(Riovalues))
median = np.median(np.array(Riovalues))
stdev = np.std(np.array(Riovalues))
print '-------------------------'
print "R Statistics:"
print "Maximum: ",np.amax(Riovalues)
print "Minimum: ", np.amin(Riovalues)
print "Mean: ",mean
print "Median: ", median
print "Stdev: ",stdev
fig4 = plt.figure()
ax4 = fig4.add_subplot(111)
ax4.hist(Riovalues, range=[0,10], normed=True,log=True,bins=np.logspace(-5,0,100))
ax4.set_xscale('log')
ax4.set_xlabel("$R$", fontsize=22)
ax4.set_ylabel("Relative Frequency",fontsize=22)
fig4.savefig('plots/R_distribution.png')
plt.show()