Implemented calculation of percentiles and Tukey hinges
[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
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49
50 activity="create program"
51 cat > $TEMPDIR/out.stat <<EOF
52 DATA LIST LIST /x * c *.
53 BEGIN DATA.
54 1 1
55 2 49
56 3 2
57 END DATA.
58
59 WEIGHT BY c.
60
61 EXAMINE
62         x
63         /STATISTICS=DESCRIPTIVES
64         .
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68
69 activity="run program"
70 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73
74 activity="compare results"
75 diff $TEMPDIR/pspp.list - << EOF
76 1.1 DATA LIST.  Reading free-form data from the command file.
77 +--------+------+
78 |Variable|Format|
79 #========#======#
80 |X       |F8.0  |
81 |C       |F8.0  |
82 +--------+------+
83
84 2.1 EXAMINE.  Case Processing Summary
85 #=#===============================#
86 # #             Cases             #
87 # #----------+---------+----------#
88 # #   Valid  | Missing |   Total  #
89 # #--+-------+-+-------+--+-------#
90 # # N|Percent|N|Percent| N|Percent#
91 #=#==#=======#=#=======#==#=======#
92 #X#52|   100%|0|     0%|52|   100%#
93 #=#==#=======#=#=======#==#=======#
94
95 2.2 EXAMINE.  Descriptives
96 #============================================#=========#==========#
97 #                                            #Statistic|Std. Error#
98 #============================================#=========#==========#
99 #XMean                                       #   2.02  |   .034   #
100 # 95% Confidence Interval for MeanLower Bound#  2.021  |          #
101 #                                 Upper Bound#  2.017  |          #
102 # 5% Trimmed Mean                            #   2.00  |          #
103 # Median                                     #   2.00  |          #
104 # Variance                                   #   .058  |          #
105 # Std. Deviation                             #   .242  |          #
106 # Minimum                                    #  1.000  |          #
107 # Maximum                                    #  3.000  |          #
108 # Range                                      #  2.000  |          #
109 # Interquartile Range                        #   .00   |          #
110 # Skewness                                   #  1.194  |   .330   #
111 # Kurtosis                                   #  15.732 |   .650   #
112 #============================================#=========#==========#
113
114 EOF
115 if [ $? -ne 0 ] ; then fail ; fi
116
117 pass