-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrimmedMeanAnalysis.py
37 lines (28 loc) · 1.2 KB
/
TrimmedMeanAnalysis.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
import json
import numpy as np
from scipy import stats
from itertools import product
with open('CleanAllDataNC.txt') as jsfNC:
dataNC = json.load(jsfNC)
with open('CleanAllDataCC.txt') as jsfCC:
dataCC = json.load(jsfCC)
NCOrigs = ['Brazil', 'United States', 'Australia', 'France', 'Portugal', 'South Africa', 'Hawaii', 'French Polynesia']
CCOrigs = ['Brazil', 'United States', 'Australia', 'France', 'Portugal', 'South Africa']
NCPairs = [(NCOrigs[i] , NCOrigs[j] ) for i in range( len(NCOrigs) ) for j in range( i , len(NCOrigs))]
CCPairs = [(CCOrigs[i] , CCOrigs[j] ) for i in range( len(CCOrigs) ) for j in range( i , len(CCOrigs))]
def trimmedMean(scores):
if len(scores) == 5:
return (np.sum(scores) - min(scores) - max(scores) ) / (len(scores) - 2)
trimEff = []
list(dataCC.keys())[0]
dataCC['471385']
list(dataCC.values())[0]
trimEff = []
heatTrimEff = dict.fromkeys( set(map(lambda x: x['heatId'], dataCC.values() )) , {'trimEff':[], 'placeDiff':[] } )
len(heatTrimEff)
for wave in dataCC.values():
if len(wave['validSubScos']) == 5:
heatTrimEff[ wave['heatId'] ] += [ np.mean(wave['validSubScos']) - trimmedMean(wave['validSubScos']) ]
absTrimEff = list(map(abs, trimEff))
for ht in heatTrimEff:
ht