projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge 'master' into 'gtk3'.
[pspp]
/
src
/
language
/
stats
/
crosstabs.q
diff --git
a/src/language/stats/crosstabs.q
b/src/language/stats/crosstabs.q
index 2246d3af1702a6940baaec20423fd31b1667161f..6adae77b030a674e81035da71ea6dd245652f828 100644
(file)
--- a/
src/language/stats/crosstabs.q
+++ b/
src/language/stats/crosstabs.q
@@
-2131,6
+2131,7
@@
static void
calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2)
{
int pt;
calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2)
{
int pt;
+ double pn1;
if (MIN (c, d) < MIN (a, b))
swap (&a, &c), swap (&b, &d);
if (MIN (c, d) < MIN (a, b))
swap (&a, &c), swap (&b, &d);
@@
-2144,13
+2145,21
@@
calc_fisher (int a, int b, int c, int d, double *fisher1, double *fisher2)
swap (&a, &c), swap (&b, &d);
}
swap (&a, &c), swap (&b, &d);
}
- *fisher1 = 0.;
- for (pt = 0; pt <= a; pt++)
- *fisher1 += Pr (a - pt, b + pt, c + pt, d - pt);
+ pn1 = Pr (a, b, c, d);
+ *fisher1 = pn1;
+ for (pt = 1; pt <= a; pt++)
+ {
+ *fisher1 += Pr (a - pt, b + pt, c + pt, d - pt);
+ }
*fisher2 = *fisher1;
*fisher2 = *fisher1;
+
for (pt = 1; pt <= b; pt++)
for (pt = 1; pt <= b; pt++)
- *fisher2 += Pr (a + pt, b - pt, c - pt, d + pt);
+ {
+ double p = Pr (a + pt, b - pt, c - pt, d + pt);
+ if (p < pn1)
+ *fisher2 += p;
+ }
}
/* Calculates chi-squares into CHISQ. MAT is a matrix with N_COLS
}
/* Calculates chi-squares into CHISQ. MAT is a matrix with N_COLS
@@
-2235,8
+2244,7
@@
calc_chisq (struct pivot_table *pt,
}
/* Fisher. */
}
/* Fisher. */
- if (f11 < 5. || f12 < 5. || f21 < 5. || f22 < 5.)
- calc_fisher (f11 + .5, f12 + .5, f21 + .5, f22 + .5, fisher1, fisher2);
+ calc_fisher (f11 + .5, f12 + .5, f21 + .5, f22 + .5, fisher1, fisher2);
}
/* Calculate Mantel-Haenszel. */
}
/* Calculate Mantel-Haenszel. */