Fix use of "export" to work with traditional shells.
[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      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51
52 activity="create program"
53 cat > $TESTFILE <<EOF
54 DATA LIST LIST /X * C *.
55 BEGIN DATA.
56 1 1
57 2 49
58 3 2
59 END DATA.
60
61 WEIGHT BY c.
62
63 EXAMINE
64         x
65         /STATISTICS=DESCRIPTIVES
66         .
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70
71 activity="run program"
72 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75
76 activity="compare results"
77 diff -b -B $TEMPDIR/pspp.list - << EOF
78 1.1 DATA LIST.  Reading free-form data from the command file.
79 +--------+------+
80 |Variable|Format|
81 #========#======#
82 |X       |F8.0  |
83 |C       |F8.0  |
84 +--------+------+
85
86 2.1 EXAMINE.  Case Processing Summary
87 #=#===============================#
88 # #             Cases             #
89 # #----------+---------+----------#
90 # #   Valid  | Missing |   Total  #
91 # #--+-------+-+-------+--+-------#
92 # # N|Percent|N|Percent| N|Percent#
93 #=#==#=======#=#=======#==#=======#
94 #X#52|   100%|0|     0%|52|   100%#
95 #=#==#=======#=#=======#==#=======#
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
116 EOF
117 if [ $? -ne 0 ] ; then fail ; fi
118
119 pass