From: John Darrington <john@darrington.wattle.id.au>
Date: Wed, 15 Jul 2009 18:25:42 +0000 (+0800)
Subject: Fixed bug reporting the significance of paired value t-test.
X-Git-Tag: sav-api~248^2~63^2~14
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8801412c9d32e74bdf21aee0bb3b29f8e877acef;p=pspp

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.
---

diff --git a/src/language/stats/t-test.q b/src/language/stats/t-test.q
index 40bf97788b..c69a6cdb5b 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 b0039df456..5092eca226 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 0000000000..f722f614fc
--- /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 <<EOF
+set format f8.3.
+data list list /A * B *.
+begin data.
+11 2
+1  1
+1  1
+end data.
+
+t-test pairs = a with b (paired).
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="compare output"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff  -b  $TEMPDIR/pspp.list - << EOF
+1.1 DATA LIST.  Reading free-form data from INLINE.
++--------+------+
+|Variable|Format|
+#========#======#
+|A       |F8.0  |
+|B       |F8.0  |
++--------+------+
+2.1 T-TEST.  Paired Sample Statistics
+#========#=====#=#==============#========#
+#        # Mean|N|Std. Deviation|SE. Mean#
+#========#=====#=#==============#========#
+#Pair 0 A#4.333|3|         5.774|   3.333#
+#       B#1.333|3|          .577|    .333#
+#========#=====#=#==============#========#
+2.2 T-TEST.  Paired Samples Correlations
+#======#=====#=#===========#====#
+#      |     #N|Correlation|Sig.#
+#======#=====#=#===========#====#
+#Pair 0|A & B#3|      1.000|.000#
+#======#=====#=#===========#====#
+2.3 T-TEST.  Paired Samples Test
+#===========#==================================================#=====#==#===============#
+#           #                Paired Differences                |     |  |               #
+#           #-----+--------------+---------------+-------------+     |  |               #
+#           #     |              |               |     95%     |     |  |               #
+#           #     |              |               +------+------+     |  |               #
+#           # Mean|Std. Deviation|Std. Error Mean| Lower| Upper|  t  |df|Sig. (2-tailed)#
+#===========#=====#==============#===============#======#======#=====#==#===============#
+#Pair 0A - B#3.000|         5.196|          3.000|-9.908|15.908|1.000| 2|           .423#
+#===========#=====#==============#===============#======#======#=====#==#===============#
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;