From 5ee84736663824fe12474b78dace867e42893a14 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 16 Jul 2009 02:25:42 +0800 Subject: [PATCH] Fixed bug reporting the significance of paired value t-test. Due to a cut and paste error, the significance of paired t-tests was wrong when the value of T was positive. Thanks to Mike Griffiths for reporting this problem. --- src/language/stats/t-test.q | 2 +- tests/automake.mk | 1 + tests/bugs/t-test-paired.sh | 117 ++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100755 tests/bugs/t-test-paired.sh diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q index 40bf9778..c69a6cdb 100644 --- a/src/language/stats/t-test.q +++ b/src/language/stats/t-test.q @@ -1279,7 +1279,7 @@ trbox_paired_populate (struct trbox *trb, tab_double (trb->t, 8, i+3, TAB_RIGHT, df, wfmt); p = gsl_cdf_tdist_P (t,df); - q = gsl_cdf_tdist_P (t,df); + q = gsl_cdf_tdist_Q (t,df); tab_double (trb->t, 9, i+3, TAB_RIGHT, 2.0* (t>0?q:p), NULL); diff --git a/tests/automake.mk b/tests/automake.mk index b0039df4..5092eca2 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -129,6 +129,7 @@ dist_TESTS = \ tests/bugs/t-test-alpha.sh \ tests/bugs/t-test-alpha2.sh \ tests/bugs/t-test-alpha3.sh \ + tests/bugs/t-test-paired.sh \ tests/bugs/temporary.sh \ tests/bugs/unwritable-dir.sh \ tests/bugs/val-labs.sh \ diff --git a/tests/bugs/t-test-paired.sh b/tests/bugs/t-test-paired.sh new file mode 100755 index 00000000..f722f614 --- /dev/null +++ b/tests/bugs/t-test-paired.sh @@ -0,0 +1,117 @@ +#!/bin/sh + +# This program tests for a bug in the paired samples T test. +# Thanks to Mike Griffiths for reporting this problem. + +TEMPDIR=/tmp/pspp-tst-$$ +TESTFILE=$TEMPDIR/`basename $0`.sps + +# ensure that top_srcdir and top_builddir are absolute +if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi +if [ -z "$top_builddir" ] ; then top_builddir=. ; fi +top_srcdir=`cd $top_srcdir; pwd` +top_builddir=`cd $top_builddir; pwd` + +PSPP=$top_builddir/src/ui/terminal/pspp + +STAT_CONFIG_PATH=$top_srcdir/config +export STAT_CONFIG_PATH + +LANG=C +export LANG + + +cleanup() +{ + if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then + echo "NOT cleaning $TEMPDIR" + return ; + fi + rm -rf $TEMPDIR +} + + +fail() +{ + echo $activity + echo FAILED + cleanup; + exit 1; +} + + +no_result() +{ + echo $activity + echo NO RESULT; + cleanup; + exit 2; +} + +pass() +{ + cleanup; + exit 0; +} + +mkdir -p $TEMPDIR + +cd $TEMPDIR + +cat >> $TESTFILE <