From ebdea3242694e7ff70e018b95663d6b463b22922 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 17 May 2019 10:16:19 +0100 Subject: t --- ministat.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ministat.c b/ministat.c index f8c4414..076186d 100644 --- a/ministat.c +++ b/ministat.c @@ -379,10 +379,20 @@ Relative(struct dataset *ds, struct dataset *rs, int confidx) double p = 100 *(1 - pvalue(welch(ds, rs), dof(ds, rs))); if (p > studentpct[confidx]) { - printf("Difference at %.1f%% confidence: %g (%.2f%%)\n", - p, - Avg(ds) - Avg(rs), - (Avg(ds) - Avg(rs)) / Avg(ds) * 100); + double c, d; + int v; + + d = Avg(ds) - Avg(rs); + + v = dof(ds, rs); + if (v > NSTUDENT) + c = student[0][confidx]; + else + c = student[v][confidx]; + c *= sqrt(Var(ds)/ds->n - Var(rs)/rs->n); + + printf("Difference at %.1f%% confidence: %g +- %g (%.2f%% +- %.3f%%)\n", p, + d, c, d / Avg(ds) * 100, c / Avg(ds) * 1000); } } -- cgit v1.2.3