2428009ad65ed9bf43df1430aed1819d20a94109
[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 export STAT_CONFIG_PATH=$top_srcdir/config
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 activity="create program"
52 cat > $TESTFILE <<EOF
53 DATA LIST LIST /x *.
54 BEGIN DATA.
55 2.00 
56 8.00 
57 5.00 
58 END DATA.
59
60 EXAMINE /x
61         /PERCENTILES=HAVERAGE.
62
63 EXAMINE /x
64         /PERCENTILES=WAVERAGE.
65
66 EXAMINE /x
67         /PERCENTILES=ROUND.
68
69 EXAMINE /x
70         /PERCENTILES=EMPIRICAL.
71
72 EXAMINE /x
73         /PERCENTILES=AEMPIRICAL.
74 EOF
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="run program"
78 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81
82 activity="compare results"
83 diff $TEMPDIR/pspp.list - << EOF
84 1.1 DATA LIST.  Reading free-form data from the command file.
85 +--------+------+
86 |Variable|Format|
87 #========#======#
88 |X       |F8.0  |
89 +--------+------+
90
91 2.1 EXAMINE.  Case Processing Summary
92 #=#=============================#
93 # #            Cases            #
94 # #---------+---------+---------#
95 # #  Valid  | Missing |  Total  #
96 # #-+-------+-+-------+-+-------#
97 # #N|Percent|N|Percent|N|Percent#
98 #=#=#=======#=#=======#=#=======#
99 #X#3|   100%|0|     0%|3|   100%#
100 #=#=#=======#=#=======#=#=======#
101
102 2.2 EXAMINE.  Percentiles
103 #================#================================#
104 #                #             Percentiles        #
105 #                #---+---+----+----+----+----+----#
106 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
107 #=#==============#===#===#====#====#====#====#====#
108 #X|HAverage      #.40|.80|2.00|5.00|8.00|8.00|8.00#
109 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
110 #=#==============#===#===#====#====#====#====#====#
111
112 3.1 EXAMINE.  Case Processing Summary
113 #=#=============================#
114 # #            Cases            #
115 # #---------+---------+---------#
116 # #  Valid  | Missing |  Total  #
117 # #-+-------+-+-------+-+-------#
118 # #N|Percent|N|Percent|N|Percent#
119 #=#=#=======#=#=======#=#=======#
120 #X#3|   100%|0|     0%|3|   100%#
121 #=#=#=======#=#=======#=#=======#
122
123 3.2 EXAMINE.  Percentiles
124 #==================#================================#
125 #                  #             Percentiles        #
126 #                  #---+---+----+----+----+----+----#
127 #                  # 5 | 10| 25 | 50 | 75 | 90 | 95 #
128 #=#================#===#===#====#====#====#====#====#
129 #X|Weighted Average#.30|.60|1.50|3.50|5.75|7.10|7.55#
130 # |Tukey's Hinges  #   |   |3.50|5.00|6.50|    |    #
131 #=#================#===#===#====#====#====#====#====#
132
133 4.1 EXAMINE.  Case Processing Summary
134 #=#=============================#
135 # #            Cases            #
136 # #---------+---------+---------#
137 # #  Valid  | Missing |  Total  #
138 # #-+-------+-+-------+-+-------#
139 # #N|Percent|N|Percent|N|Percent#
140 #=#=#=======#=#=======#=#=======#
141 #X#3|   100%|0|     0%|3|   100%#
142 #=#=#=======#=#=======#=#=======#
143
144 4.2 EXAMINE.  Percentiles
145 #================#================================#
146 #                #             Percentiles        #
147 #                #---+---+----+----+----+----+----#
148 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
149 #=#==============#===#===#====#====#====#====#====#
150 #X|Rounded       #.00|.00|2.00|5.00|5.00|8.00|8.00#
151 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
152 #=#==============#===#===#====#====#====#====#====#
153
154 5.1 EXAMINE.  Case Processing Summary
155 #=#=============================#
156 # #            Cases            #
157 # #---------+---------+---------#
158 # #  Valid  | Missing |  Total  #
159 # #-+-------+-+-------+-+-------#
160 # #N|Percent|N|Percent|N|Percent#
161 #=#=#=======#=#=======#=#=======#
162 #X#3|   100%|0|     0%|3|   100%#
163 #=#=#=======#=#=======#=#=======#
164
165 5.2 EXAMINE.  Percentiles
166 #================#==================================#
167 #                #              Percentiles         #
168 #                #----+----+----+----+----+----+----#
169 #                #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
170 #=#==============#====#====#====#====#====#====#====#
171 #X|Empirical     #2.00|2.00|2.00|5.00|8.00|8.00|8.00#
172 # |Tukey's Hinges#    |    |3.50|5.00|6.50|    |    #
173 #=#==============#====#====#====#====#====#====#====#
174
175 6.1 EXAMINE.  Case Processing Summary
176 #=#=============================#
177 # #            Cases            #
178 # #---------+---------+---------#
179 # #  Valid  | Missing |  Total  #
180 # #-+-------+-+-------+-+-------#
181 # #N|Percent|N|Percent|N|Percent#
182 #=#=#=======#=#=======#=#=======#
183 #X#3|   100%|0|     0%|3|   100%#
184 #=#=#=======#=#=======#=#=======#
185
186 6.2 EXAMINE.  Percentiles
187 #==========================#==================================#
188 #                          #              Percentiles         #
189 #                          #----+----+----+----+----+----+----#
190 #                          #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
191 #=#========================#====#====#====#====#====#====#====#
192 #X|Empirical with averaging#2.00|2.00|2.00|5.00|8.00|8.00|8.00#
193 # |Tukey's Hinges          #    |    |3.50|5.00|6.50|    |    #
194 #=#========================#====#====#====#====#====#====#====#
195
196 EOF
197 if [ $? -ne 0 ] ; then fail ; fi
198
199 pass