diff options
-rw-r--r-- | ministat.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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); } } |