a5d74e1251338f04293d1991dae0305050a95818
[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 diff -b -B $TEMPDIR/pspp.list - << EOF
79 1.1 DATA LIST.  Reading free-form data from the command file.
80 +--------+------+
81 |Variable|Format|
82 #========#======#
83 |X       |F8.0  |
84 |C       |F8.0  |
85 +--------+------+
86
87 2.1 EXAMINE.  Case Processing Summary
88 #=#===============================#
89 # #             Cases             #
90 # #----------+---------+----------#
91 # #   Valid  | Missing |   Total  #
92 # #--+-------+-+-------+--+-------#
93 # # N|Percent|N|Percent| N|Percent#
94 #=#==#=======#=#=======#==#=======#
95 #X#52|   100%|0|     0%|52|   100%#
96 #=#==#=======#=#=======#==#=======#
97
98 2.2 EXAMINE.  Descriptives
99 #============================================#=========#==========#
100 #                                            #Statistic|Std. Error#
101 #============================================#=========#==========#
102 #XMean                                       #   2.02  |   .034   #
103 # 95% Confidence Interval for MeanLower Bound#  2.021  |          #
104 #                                 Upper Bound#  2.017  |          #
105 # 5% Trimmed Mean                            #   2.00  |          #
106 # Median                                     #   2.00  |          #
107 # Variance                                   #   .058  |          #
108 # Std. Deviation                             #   .242  |          #
109 # Minimum                                    #  1.000  |          #
110 # Maximum                                    #  3.000  |          #
111 # Range                                      #  2.000  |          #
112 # Interquartile Range                        #   .00   |          #
113 # Skewness                                   #  1.194  |   .330   #
114 # Kurtosis                                   #  15.732 |   .650   #
115 #============================================#=========#==========#
116
117 EOF
118 if [ $? -ne 0 ] ; then fail ; fi
119
120 pass