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