Checkin of new directory structure.
[pspp-builds.git] / tests / command / trimmed-mean.sh
1 #!/bin/sh
2
3 # This program tests  the Trimmed Mean calculation, in the case
4 # where the data is weighted towards the centre
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_builddir  are absolute
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
12 top_builddir=`cd $top_builddir; pwd`
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20
21 cleanup()
22 {
23      cd /
24      rm -rf $TEMPDIR
25 }
26
27
28 fail()
29 {
30     echo $activity
31     echo FAILED
32     cleanup;
33     exit 1;
34 }
35
36
37 no_result()
38 {
39     echo $activity
40     echo NO RESULT;
41     cleanup;
42     exit 2;
43 }
44
45 pass()
46 {
47     cleanup;
48     exit 0;
49 }
50
51 mkdir -p $TEMPDIR
52
53 cd $TEMPDIR
54
55
56 activity="create program"
57 cat > $TESTFILE <<EOF
58 DATA LIST LIST /X * C *.
59 BEGIN DATA.
60 1 1
61 2 49
62 3 2
63 END DATA.
64
65 WEIGHT BY c.
66
67 EXAMINE
68         x
69         /STATISTICS=DESCRIPTIVES
70         .
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="run program"
76 $SUPERVISOR $top_builddir/src/pspp -o raw-ascii $TESTFILE
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79
80 activity="compare results"
81 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
82 diff -b  $TEMPDIR/pspp.list - << EOF
83 1.1 DATA LIST.  Reading free-form data from INLINE.
84 +--------+------+
85 |Variable|Format|
86 #========#======#
87 |X       |F8.0  |
88 |C       |F8.0  |
89 +--------+------+
90 2.1 EXAMINE.  Case Processing Summary
91 #=#===============================#
92 # #             Cases             #
93 # #----------+---------+----------#
94 # #   Valid  | Missing |   Total  #
95 # #--+-------+-+-------+--+-------#
96 # # N|Percent|N|Percent| N|Percent#
97 #=#==#=======#=#=======#==#=======#
98 #X#52|   100%|0|     0%|52|   100%#
99 #=#==#=======#=#=======#==#=======#
100 2.2 EXAMINE.  Descriptives
101 #============================================#=========#==========#
102 #                                            #Statistic|Std. Error#
103 #============================================#=========#==========#
104 #XMean                                       #   2.02  |   .034   #
105 # 95% Confidence Interval for MeanLower Bound#  2.021  |          #
106 #                                 Upper Bound#  2.017  |          #
107 # 5% Trimmed Mean                            #   2.00  |          #
108 # Median                                     #   2.00  |          #
109 # Variance                                   #   .058  |          #
110 # Std. Deviation                             #   .242  |          #
111 # Minimum                                    #  1.000  |          #
112 # Maximum                                    #  3.000  |          #
113 # Range                                      #  2.000  |          #
114 # Interquartile Range                        #   .00   |          #
115 # Skewness                                   #  1.194  |   .330   #
116 # Kurtosis                                   #  15.732 |   .650   #
117 #============================================#=========#==========#
118 EOF
119 if [ $? -ne 0 ] ; then fail ; fi
120
121 pass