summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-05-17 10:24:48 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-05-17 10:53:01 +0100
commit5f671dafb9e36ea5796bf22caaced54541270040 (patch)
treefc9e90aef9b5b6424c1169081c61450d8c790382
parentebdea3242694e7ff70e018b95663d6b463b22922 (diff)
dof
-rw-r--r--ministat.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ministat.c b/ministat.c
index 076186d..94fa996 100644
--- a/ministat.c
+++ b/ministat.c
@@ -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);
}
}