Skip to content
Myr

scripts: add welch's t test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Yasuaki Uechi · committed by David Peter · parent 02962d1 · Browse files · 1 file+28 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+28 added−0 removed

  • other:+28 added−0 removed

1 file+28 added−0 removed

added:scripts/welch_ttest.py+28 added
1#!/usr/bin/python23import argparse4import json5from scipy import stats67parser = argparse.ArgumentParser()8parser.add_argument("file", help="JSON file with benchmark results")9args = parser.parse_args()1011with open(args.file) as f:12 results = json.load(f)["results"]1314a, b = [x["command"] for x in results[:2]]15X, Y = [x["times"] for x in results[:2]]1617print("Command 1: {}".format(a))18print("Command 2: {}\n".format(b))1920t, p = stats.ttest_ind(X, Y, equal_var=False)21th = 0.0522dispose = p < th23print("t = {}, p = {}".format(t, p))24print("p < {} = {}\n".format(th, dispose))25if dispose:26 print("There is a difference between the two benchmarks.")27else:28 print("The two benchmarks are almost the same.")