summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-05-17 10:16:19 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-05-17 10:16:19 +0100
commitebdea3242694e7ff70e018b95663d6b463b22922 (patch)
tree99c1eae36e2e2ab1912642e3a47284f4df63f36d
parent3d0c1991fdb19211d33653c3ba8e69364d1d6927 (diff)
t
-rw-r--r--ministat.c18
1 files 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);
}
}