summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2024-07-02 09:36:57 +0200
committerBirte Kristina Friesel <birte.friesel@uos.de>2024-07-02 09:36:57 +0200
commit62fdb7ee120fa0f9c8bf837cce546e2ae294fff7 (patch)
tree5cf214bf10d287b7ff41a6d39eaa9bacfbcb1477
parentf1dfa367044344760331d79361363ba1860f2367 (diff)
add ttest-ind utility
-rwxr-xr-xbin/ttest-ind.py31
1 files changed, 31 insertions, 0 deletions
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:])