X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fstats%2Ffrequencies.at;h=cf7913b40d57e8d4509f2b2b38da2437f8411679;hb=d97c0f1ed2858c48173c023964cec8234b5bc831;hp=9eae09e8364e974c447f4be8505abd9190323788;hpb=fe8dc2171009e90d2335f159d05f7e6660e24780;p=pspp diff --git a/tests/language/stats/frequencies.at b/tests/language/stats/frequencies.at index 9eae09e836..cf7913b40d 100644 --- a/tests/language/stats/frequencies.at +++ b/tests/language/stats/frequencies.at @@ -1,21 +1,49 @@ +dnl PSPP - a program for statistical analysis. +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl AT_BANNER([FREQUENCIES procedure]) -AT_SETUP([FREQUENCIES string variable crash]) +AT_SETUP([FREQUENCIES string variable]) AT_DATA([frequencies.sps], [DATA LIST FREE/ name (A8) value * quantity . BEGIN DATA. -Cables 829 3 +foo 1 5 +bar 2 6 +baz 1 9 +quux 3 1 +bar 1 2 +baz 4 3 +baz 1 4 +baz 1 1 +foo 6 0 +quux 5 8 END DATA. EXECUTE. -FREQUENCIES /VAR = name. +FREQUENCIES /VAR = name/ORDER=ANALYSIS. ]) -AT_CHECK([pspp -O format=csv frequencies.sps], [0], - [Table: name +AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl +Table: name Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent -,Cables ,1,100.00,100.00,100.00 -Total,,1,100.0,100.0, +,bar ,2,20.00,20.00,20.00 +,baz ,4,40.00,40.00,60.00 +,foo ,2,20.00,20.00,80.00 +,quux ,2,20.00,20.00,100.00 +Total,,10,100.0,100.0, ]) AT_CLEANUP @@ -31,7 +59,7 @@ begin data. 3 4 end data. -frequencies v1 v2/statistics=none. +frequencies v1 v2/statistics=none/ORDER=VARIABLE. frequencies v1 v2/statistics=none. ]) AT_CHECK([pspp -O format=csv frequencies.sps], [0], @@ -69,6 +97,29 @@ Total,,4,100.0,100.0, ]) AT_CLEANUP +# Test that the LIMIT specification works. +AT_SETUP([FREQUENCIES with LIMIT]) +AT_DATA([frequencies.sps], + [data list free /v1 v2. +begin data. +0 1 +2 5 +4 3 +3 5 +end data. + +frequencies v1 v2/statistics=none/FORMAT=LIMIT(3). +]) +AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl +Table: v2 +Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent +,1.00,1,25.00,25.00,25.00 +,3.00,1,25.00,25.00,50.00 +,5.00,2,50.00,50.00,100.00 +Total,,4,100.0,100.0, +]) +AT_CLEANUP + # Tests for a bug where PSPP would crash when a FREQUENCIES command # was used with the HTML output driver. AT_SETUP([FREQUENCIES HTML output crash]) @@ -141,6 +192,36 @@ Reading free-form data from INLINE. ]) AT_CLEANUP +dnl Check that histogram subcommand runs wihout crashing +AT_SETUP([FREQUENCIES histogram crash]) +AT_DATA([frequencies.sps], + [data list notable list /x * w *. +begin data. +1 4 +34 10 +-9 15 +232 6 +11 4 +134 1 +9 5 +32 16 +-2 6 +2 16 +20 6 +end data. + +weight by w. + +frequencies /x + /format=notable + /statistics=none + /histogram=minimum(0) maximum(50) percent(5) normal. +]) +# Cannot use the CSV driver for this because it does not output charts +# at all. +AT_CHECK([pspp -O format=pdf frequencies.sps], [0], [ignore]) +AT_CLEANUP + # Tests for a bug which crashed PSPP when the median and a histogram # were both requested. AT_SETUP([FREQUENCIES median with histogram crash]) @@ -152,18 +233,8 @@ end data. frequencies /x /histogram /STATISTICS=median. ]) -AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl -Table: x -Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent -,1.00,1,100.00,100.00,100.00 -Total,,1,100.0,100.0, - -Table: x -N,Valid,1 -,Missing,0 -S.E. Kurt,,.00 -,50 (Median),1.00 -]) +AT_CHECK([pspp -O format=csv frequencies.sps], [0], [ignore]) +dnl Ignore output - No crash test. AT_CLEANUP # Tests for a bug which caused FREQUENCIES following TEMPORARY to @@ -496,6 +567,7 @@ FREQUENCIES VAR=x /PERCENTILES = 0 25 50 75 100. ]) + AT_CHECK([pspp -O format=csv frequencies.sps], [0], [Table: X Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent @@ -520,3 +592,241 @@ Percentiles,0,1.00 ,100,5.00 ]) AT_CLEANUP + +AT_SETUP([FREQUENCIES dichotomous histogram]) +AT_DATA([frequencies.sps], [dnl +data list notable list /d4 *. +begin data. +0 +0 +0 +1 +0 +0 +0 +0 +1 +0 +0 +0 +0 +0 +1 +2 +0 +end data. + +FREQUENCIES + /VARIABLES = d4 + /FORMAT=AVALUE TABLE + /HISTOGRAM=NORMAL + . +]) + +AT_CHECK([pspp frequencies.sps], [0], [ignore]) +AT_CLEANUP + + +AT_SETUP([FREQUENCIES median]) +AT_DATA([median.sps], [dnl +data list notable list /x *. +begin data. +1 +2 +3000000 +end data. + +FREQUENCIES + /VARIABLES = x + /STATISTICS = MEDIAN + . +]) + +AT_CHECK([pspp median.sps -O format=csv], [0], [dnl +Table: x +Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent +,1.00,1,33.33,33.33,33.33 +,2.00,1,33.33,33.33,66.67 +,3000000.00,1,33.33,33.33,100.00 +Total,,3,100.0,100.0, + +Table: x +N,Valid,3 +,Missing,0 +Percentiles,50 (Median),2.00 +]) +AT_CLEANUP + +AT_SETUP([FREQUENCIES variance]) +AT_DATA([variance.sps], [dnl +data list notable list /forename (A12) height. +begin data. +Ahmed 188 +bertram 167 +Catherine 134 +David 109 +end data. + +FREQUENCIES + /VARIABLES = height + /STATISTICS = VARIANCE. +]) + +AT_CHECK([pspp variance.sps -O format=csv], [0], [dnl +Table: height +Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent +,109.00,1,25.00,25.00,25.00 +,134.00,1,25.00,25.00,50.00 +,167.00,1,25.00,25.00,75.00 +,188.00,1,25.00,25.00,100.00 +Total,,4,100.0,100.0, + +Table: height +N,Valid,4 +,Missing,0 +Variance,,1223.00 +]) +AT_CLEANUP + +AT_SETUP([FREQUENCIES default statistics]) +AT_DATA([median.sps], [dnl +data list notable list /x *. +begin data. +10 +20 +3000000 +end data. + +FREQUENCIES + /VARIABLES = x + /STATISTICS + . + +FREQUENCIES + /VARIABLES = x + /STATISTICS = DEFAULT + . +]) + +AT_CHECK([pspp median.sps -O format=csv], [0], [dnl +Table: x +Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent +,10.00,1,33.33,33.33,33.33 +,20.00,1,33.33,33.33,66.67 +,3000000.00,1,33.33,33.33,100.00 +Total,,3,100.0,100.0, + +Table: x +N,Valid,3 +,Missing,0 +Mean,,1000010.00 +Std Dev,,1732042.15 +Minimum,,10.00 +Maximum,,3000000.00 + +Table: x +Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent +,10.00,1,33.33,33.33,33.33 +,20.00,1,33.33,33.33,66.67 +,3000000.00,1,33.33,33.33,100.00 +Total,,3,100.0,100.0, + +Table: x +N,Valid,3 +,Missing,0 +Mean,,1000010.00 +Std Dev,,1732042.15 +Minimum,,10.00 +Maximum,,3000000.00 +]) +AT_CLEANUP + + + +AT_SETUP([FREQUENCIES no valid data]) +AT_DATA([empty.sps], [dnl +data list notable list /x *. +begin data. +. +. +. +end data. + +FREQUENCIES + /VARIABLES = x + /STATISTICS = ALL + . +]) + +AT_CHECK([pspp empty.sps -O format=csv], [0], [dnl +Table: x +Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent +,. ,3,100.00,Missing, +Total,,3,100.0,100.0, + +Table: x +N,Valid,0 +,Missing,3 +Mean,,. +S.E. Mean,,. +Mode,,. +Std Dev,,. +Variance,,. +Kurtosis,,. +S.E. Kurt,,. +Skewness,,. +S.E. Skew,,. +Range,,. +Minimum,,. +Maximum,,. +Sum,,. +Percentiles,,. +]) + +AT_CLEANUP + + +AT_SETUP([FREQUENCIES histogram no valid cases]) +AT_DATA([empty.sps], [dnl +data list notable list /x w *. +begin data. +1 . +2 . +3 . +end data. + +weight by w. + +FREQUENCIES + /VARIABLES = x + /histogram + . +]) + +AT_CHECK([pspp empty.sps -O format=csv], [0], [ignore]) + +AT_CLEANUP + +AT_SETUP([FREQUENCIES percentiles + histogram bug#48128]) +AT_DATA([bug.sps], [dnl +SET FORMAT=F8.0. + +INPUT PROGRAM. + LOOP I=1 TO 10. + COMPUTE SCORE=EXP(NORMAL(1)). + END CASE. + END LOOP. + END FILE. +END INPUT PROGRAM. + +FREQUENCIES VARIABLES=SCORE +/FORMAT=NOTABLE +/STATISTICS=ALL +/PERCENTILES=1 10 20 30 40 50 60 70 80 90 99 +/HISTOGRAM. + +]) + +AT_CHECK([pspp bug.sps], [0], [ignore]) + +AT_CLEANUP