diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2019-05-17 10:24:48 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2019-05-17 10:53:01 +0100 |
commit | 5f671dafb9e36ea5796bf22caaced54541270040 (patch) | |
tree | fc9e90aef9b5b6424c1169081c61450d8c790382 | |
parent | ebdea3242694e7ff70e018b95663d6b463b22922 (diff) |
dof
-rw-r--r-- | ministat.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -317,13 +317,13 @@ Vitals(struct dataset *ds, int flag) static double dof(struct dataset *a, struct dataset *b) { + double sa = Var(a) / a->sn; + double sb = Var(b) / b->sn; double v; - v = Var(a) / a->sn + Var(b) / b->sn; + v = sa + sb; v *= v; - - v /= (Var(a) * Var(a) / (a->sn * a->sn * (a->sn - 1)) + - (Var(b) * Var(b) / (b->sn * b->sn * (b->sn - 1)))); + v /= sa * sa / (a->sn - 1) + sb * sb / (b->sn - 1); return v; } @@ -389,10 +389,10 @@ Relative(struct dataset *ds, struct dataset *rs, int confidx) c = student[0][confidx]; else c = student[v][confidx]; - c *= sqrt(Var(ds)/ds->n - Var(rs)/rs->n); + 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); + d, c, d / Avg(ds) * 100, c / Avg(ds) * 100); } } |