summaryrefslogtreecommitdiff
path: root/bin/ttest-ind.py
blob: ebed6af28dbb6249114d83c91966a1bbd0a712d3 (plain)
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
#!/usr/bin/env python3

import json
import sys
from scipy.stats import ttest_ind


def main(pvalue, file1, file2, macro=None):
    with open(file1, "r") as f:
        data1 = json.load(f)
    with open(file2, "r") as f:
        data2 = json.load(f)
    result = ttest_ind(data1, data2)

    pvalue = float(pvalue)

    print(f"% {result}")
    if macro is None:
        print(r"\drefset{ttest/pvalue}{" + str(result.pvalue) + "}")
    if result.pvalue < pvalue:
        if macro:
            print("\\def\\" + macro + "{$p < " + f"{pvalue:0.2f}" + "$}")
        sys.exit(0)
    else:
        if macro:
            print("\\def\\" + macro + "{$p \\ge " + f"{pvalue:0.2f}" + "$}")
        sys.exit(1)


if __name__ == "__main__":
    main(*sys.argv[1:])