83cace7e254fcc28eee29ffc90f114dc7c357d95
[pspp-builds.git] / tests / command / percentiles.sh
1 #!/bin/sh
2
3 # This program tests the PERCENTILES subcommand of the FREQUENCIES cmd
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 activity="create prog"
49 cat > $TEMPDIR/percents.stat <<EOF
50 data list free /z x(f3.2) y(f3.0) d(a30).
51 begin data.
52 1 3 4 apples
53 2 5 6 pairs
54 3 4 5 bannanas
55 4 3 9 pairs
56 5 1 2 pairs
57 6 4 5 apricots
58 7 4 4 bannanas
59 8 4 5 apples
60 9 3 3 peaches
61 10 2 3 coconuts
62 end data.
63
64 frequencies z   /statistics=all /percentiles = 5,10,30,90.
65
66 finish.
67
68 EOF
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71
72 activity="run prog"
73 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/percents.stat
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76 activity="compare output"
77 diff -b -B $TEMPDIR/pspp.list - <<EOF
78 1.1 FREQUENCIES.  Z: 
79 +-----------+--------+---------+--------+--------+--------+
80 |           |        |         |        |  Valid |   Cum  |
81 |Value Label|  Value |Frequency| Percent| Percent| Percent|
82 #===========#========#=========#========#========#========#
83 |           |     .01|        1|    10.0|    10.0|    10.0|
84 |           |     .02|        1|    10.0|    10.0|    20.0|
85 |           |     .03|        1|    10.0|    10.0|    30.0|
86 |           |     .04|        1|    10.0|    10.0|    40.0|
87 |           |     .05|        1|    10.0|    10.0|    50.0|
88 |           |     .06|        1|    10.0|    10.0|    60.0|
89 |           |     .07|        1|    10.0|    10.0|    70.0|
90 |           |     .08|        1|    10.0|    10.0|    80.0|
91 |           |     .09|        1|    10.0|    10.0|    90.0|
92 |           |     .10|        1|    10.0|    10.0|   100.0|
93 #===========#========#=========#========#========#========#
94 |               Total|       10|   100.0|   100.0|        |
95 +--------------------+---------+--------+--------+--------+
96
97 Mean            .055
98 S.E. Mean       .010
99 Median          .   
100 Mode            .   
101 Std Dev         .030
102 Variance        .001
103 Kurtosis      -1.200
104 S.E. Kurt      1.334
105 Skewness        .000
106 S.E. Skew       .687
107 Range           .090
108 Minimum         .010
109 Maximum         .100
110 Sum             .550
111 Percentile 5    .   
112 Percentile 10   .010
113 Percentile 29   .020
114 Percentile 90   .090
115 EOF
116 if [ $? -ne 0 ] ; then fail ; fi
117
118
119 pass;