Add scratch file handles.
[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 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
80 1.1 DATA LIST.  Reading free-form data from INLINE.
81 +--------+------+
82 |Variable|Format|
83 #========#======#
84 |X       |F8.0  |
85 |C       |F8.0  |
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 2.2 EXAMINE.  Descriptives
98 #============================================#=========#==========#
99 #                                            #Statistic|Std. Error#
100 #============================================#=========#==========#
101 #XMean                                       #   2.02  |   .034   #
102 # 95% Confidence Interval for MeanLower Bound#  2.021  |          #
103 #                                 Upper Bound#  2.017  |          #
104 # 5% Trimmed Mean                            #   2.00  |          #
105 # Median                                     #   2.00  |          #
106 # Variance                                   #   .058  |          #
107 # Std. Deviation                             #   .242  |          #
108 # Minimum                                    #  1.000  |          #
109 # Maximum                                    #  3.000  |          #
110 # Range                                      #  2.000  |          #
111 # Interquartile Range                        #   .00   |          #
112 # Skewness                                   #  1.194  |   .330   #
113 # Kurtosis                                   #  15.732 |   .650   #
114 #============================================#=========#==========#
115 EOF
116 if [ $? -ne 0 ] ; then fail ; fi
117
118 pass