Sat Jul 30 21:54:23 2005 Ben Pfaff <blp@gnu.org>
[pspp-builds.git] / tests / command / examine-percentiles.sh
1 #!/bin/sh
2
3 # This program tests  the PERCENTILES subcommand of the EXAMINE command.
4 # In particular it tests that it behaves properly when there are only 
5 # a few cases
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 here=`pwd`;
11
12 # ensure that top_srcdir is absolute
13 cd $top_srcdir; top_srcdir=`pwd`
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
21      cd /
22      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50
51 cd $TEMPDIR
52
53 activity="create program"
54 cat > $TESTFILE <<EOF
55 DATA LIST LIST /X *.
56 BEGIN DATA.
57 2.00 
58 8.00 
59 5.00 
60 END DATA.
61
62 EXAMINE /x
63         /PERCENTILES=HAVERAGE.
64
65 EXAMINE /x
66         /PERCENTILES=WAVERAGE.
67
68 EXAMINE /x
69         /PERCENTILES=ROUND.
70
71 EXAMINE /x
72         /PERCENTILES=EMPIRICAL.
73
74 EXAMINE /x
75         /PERCENTILES=AEMPIRICAL.
76 EOF
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="run program"
80 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83
84 activity="compare results"
85 diff -b -B $TEMPDIR/pspp.list - << EOF
86 1.1 DATA LIST.  Reading free-form data from the command file.
87 +--------+------+
88 |Variable|Format|
89 #========#======#
90 |X       |F8.0  |
91 +--------+------+
92
93 2.1 EXAMINE.  Case Processing Summary
94 #=#=============================#
95 # #            Cases            #
96 # #---------+---------+---------#
97 # #  Valid  | Missing |  Total  #
98 # #-+-------+-+-------+-+-------#
99 # #N|Percent|N|Percent|N|Percent#
100 #=#=#=======#=#=======#=#=======#
101 #X#3|   100%|0|     0%|3|   100%#
102 #=#=#=======#=#=======#=#=======#
103
104 2.2 EXAMINE.  Percentiles
105 #================#================================#
106 #                #             Percentiles        #
107 #                #---+---+----+----+----+----+----#
108 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
109 #=#==============#===#===#====#====#====#====#====#
110 #X|HAverage      #.40|.80|2.00|5.00|8.00|8.00|8.00#
111 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
112 #=#==============#===#===#====#====#====#====#====#
113
114 3.1 EXAMINE.  Case Processing Summary
115 #=#=============================#
116 # #            Cases            #
117 # #---------+---------+---------#
118 # #  Valid  | Missing |  Total  #
119 # #-+-------+-+-------+-+-------#
120 # #N|Percent|N|Percent|N|Percent#
121 #=#=#=======#=#=======#=#=======#
122 #X#3|   100%|0|     0%|3|   100%#
123 #=#=#=======#=#=======#=#=======#
124
125 3.2 EXAMINE.  Percentiles
126 #==================#================================#
127 #                  #             Percentiles        #
128 #                  #---+---+----+----+----+----+----#
129 #                  # 5 | 10| 25 | 50 | 75 | 90 | 95 #
130 #=#================#===#===#====#====#====#====#====#
131 #X|Weighted Average#.30|.60|1.50|3.50|5.75|7.10|7.55#
132 # |Tukey's Hinges  #   |   |3.50|5.00|6.50|    |    #
133 #=#================#===#===#====#====#====#====#====#
134
135 4.1 EXAMINE.  Case Processing Summary
136 #=#=============================#
137 # #            Cases            #
138 # #---------+---------+---------#
139 # #  Valid  | Missing |  Total  #
140 # #-+-------+-+-------+-+-------#
141 # #N|Percent|N|Percent|N|Percent#
142 #=#=#=======#=#=======#=#=======#
143 #X#3|   100%|0|     0%|3|   100%#
144 #=#=#=======#=#=======#=#=======#
145
146 4.2 EXAMINE.  Percentiles
147 #================#================================#
148 #                #             Percentiles        #
149 #                #---+---+----+----+----+----+----#
150 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
151 #=#==============#===#===#====#====#====#====#====#
152 #X|Rounded       #.00|.00|2.00|5.00|5.00|8.00|8.00#
153 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
154 #=#==============#===#===#====#====#====#====#====#
155
156 5.1 EXAMINE.  Case Processing Summary
157 #=#=============================#
158 # #            Cases            #
159 # #---------+---------+---------#
160 # #  Valid  | Missing |  Total  #
161 # #-+-------+-+-------+-+-------#
162 # #N|Percent|N|Percent|N|Percent#
163 #=#=#=======#=#=======#=#=======#
164 #X#3|   100%|0|     0%|3|   100%#
165 #=#=#=======#=#=======#=#=======#
166
167 5.2 EXAMINE.  Percentiles
168 #================#==================================#
169 #                #              Percentiles         #
170 #                #----+----+----+----+----+----+----#
171 #                #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
172 #=#==============#====#====#====#====#====#====#====#
173 #X|Empirical     #2.00|2.00|2.00|5.00|8.00|8.00|8.00#
174 # |Tukey's Hinges#    |    |3.50|5.00|6.50|    |    #
175 #=#==============#====#====#====#====#====#====#====#
176
177 6.1 EXAMINE.  Case Processing Summary
178 #=#=============================#
179 # #            Cases            #
180 # #---------+---------+---------#
181 # #  Valid  | Missing |  Total  #
182 # #-+-------+-+-------+-+-------#
183 # #N|Percent|N|Percent|N|Percent#
184 #=#=#=======#=#=======#=#=======#
185 #X#3|   100%|0|     0%|3|   100%#
186 #=#=#=======#=#=======#=#=======#
187
188 6.2 EXAMINE.  Percentiles
189 #==========================#==================================#
190 #                          #              Percentiles         #
191 #                          #----+----+----+----+----+----+----#
192 #                          #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
193 #=#========================#====#====#====#====#====#====#====#
194 #X|Empirical with averaging#2.00|2.00|2.00|5.00|8.00|8.00|8.00#
195 # |Tukey's Hinges          #    |    |3.50|5.00|6.50|    |    #
196 #=#========================#====#====#====#====#====#====#====#
197
198 EOF
199 if [ $? -ne 0 ] ; then fail ; fi
200
201 pass