Created
June 24, 2017 13:47
-
-
Save seungwonpark/963fe1da9a4a104b60641c67dd3e2fd2 to your computer and use it in GitHub Desktop.
HAAFOR Challenge calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# grouping = [[0,3],[1,2]] | |
# filename = 'hfc_20170614_example.csv' | |
# grouping = [[x for x in range(200*y, 200*(y+1))] for y in range(10)] | |
with open('random.csv', 'a') as f2: | |
while(1): | |
grouping_rand = np.random.permutation(2000) | |
grouping = [] | |
for i in range(10): | |
grouping.append(grouping_rand[200*i:200*i+200]) | |
filename = 'hfc_20170614_comp.csv' | |
with open(filename, 'r') as f: | |
v = list(zip(*[list(map(float,x.split(','))) for x in f.read().split('\n')[:-1]])) | |
G = [] | |
for arr in grouping: | |
G.append(np.array([v[x] for x in arr])) | |
TICS = sum([np.sum(np.corrcoef(G[x])) for x in range(10)]) | |
CARS = np.sum(np.corrcoef([np.mean(G[x], axis=0) for x in range(10)])) | |
print(TICS, CARS, CARS/TICS) | |
f2.write('%lf %lf %lf %s\n' % (TICS, CARS, CARS/TICS, ",".join(map(str,grouping_rand)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://swpark.ddns.net/uploads/hfc_20170614_comp.csv