comparison talk/code/show_mc.py @ 67:1aa38f4846e0

showalgo: show the rank
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 18 May 2016 17:43:45 -0400
parents 916349600c4b
children 5510ac95a3d3
comparison
equal deleted inserted replaced
66:916349600c4b 67:1aa38f4846e0
93 Pfile = open("P", "w") 93 Pfile = open("P", "w")
94 Qfile = open("Q", "w") 94 Qfile = open("Q", "w")
95 RemFile = open("remaining", "w") 95 RemFile = open("remaining", "w")
96 Ptotfile = open("Ptotal", "w") 96 Ptotfile = open("Ptotal", "w")
97 Qtotfile = open("Qtotal", "w") 97 Qtotfile = open("Qtotal", "w")
98 medc_idxfile = open("medc_idx", "w")
98 jackpot = open("jackpot", "w") 99 jackpot = open("jackpot", "w")
99 100
100 # FIXME: Figure out what to do about NaNs. 101 # FIXME: Figure out what to do about NaNs.
101 102
102 n = len(X) 103 n = len(X)
164 R = [n_minus - 1]*n_plus 165 R = [n_minus - 1]*n_plus
165 166
166 Ltot = 0 167 Ltot = 0
167 Rtot = n_minus*n_plus 168 Rtot = n_minus*n_plus
168 medc_idx = Rtot//2 169 medc_idx = Rtot//2
170 medc_idxfile.write("%s\n" % medc_idx)
169 171
170 Lfile.write("%s\n" % L) 172 Lfile.write("%s\n" % L)
171 Rfile.write("%s\n" % R) 173 Rfile.write("%s\n" % R)
172 RemFile.write("%s\n" % Rtot) 174 RemFile.write("%s\n" % Rtot)
173 175
257 else: 259 else:
258 return 0 260 return 0
259 261
260 262
261 def main(): 263 def main():
262 data = np.random.uniform(size=18) 264 data = np.random.uniform(size=26)
263 265
264 mc = medcouple_1d(data) 266 mc = medcouple_1d(data)
265 with open("mc", "w") as f: 267 with open("mc", "w") as f:
266 f.write("%s\n" % mc) 268 f.write("%s\n" % mc)
267 269