From 62fdb7ee120fa0f9c8bf837cce546e2ae294fff7 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Tue, 2 Jul 2024 09:36:57 +0200 Subject: add ttest-ind utility --- bin/ttest-ind.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 bin/ttest-ind.py (limited to 'bin') diff --git a/bin/ttest-ind.py b/bin/ttest-ind.py new file mode 100755 index 0000000..c1859f0 --- /dev/null +++ b/bin/ttest-ind.py @@ -0,0 +1,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"% p = {result.pvalue}") + 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:]) -- cgit v1.2.3