-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat.py
31 lines (23 loc) · 1011 Bytes
/
stat.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
import numpy as np
import pandas as pd
from scipy.stats import mannwhitneyu, ttest_ind
import scipy.stats as stats
df = pd.read_csv('log/result.csv')
subject_groups = {subject: df[df['Adaptive_Scheme'] == subject]['Iteration'].tolist()
for subject in df['Adaptive_Scheme'].unique()}
first_subject = list(subject_groups.keys())[0]
other_subjects = list(subject_groups.keys())[1:]
results = {}
for subject in other_subjects:
first_values = subject_groups[first_subject]
second_values = subject_groups[subject]
t_stat, p_value = stats.ttest_ind(first_values, second_values, equal_var=False)
p_value_one_tailed = p_value / 2 if t_stat > 0 else 1 - (p_value / 2)
results[subject] = {
't_statistic': t_stat,
'p_value': p_value_one_tailed
}
# Print the results
for subject, result in results.items():
print(f"Test comparing {first_subject} vs {subject}:")
print(f" t-statistic: {result['t_statistic']:.4f}, p-value: {result['p_value']:.4f}")