FREQUENCIES: fixed VARIANCE output - fixes bug #50366
authorFriedrich Beckmann <friedrich.beckmann@gmx.de>
Tue, 21 Feb 2017 14:52:41 +0000 (15:52 +0100)
committerFriedrich Beckmann <friedrich.beckmann@gmx.de>
Tue, 21 Feb 2017 14:52:41 +0000 (15:52 +0100)
The FREQUENCIES command output the mean instead of variance result when
variance was requested. The bug and a patch was reported on savannah.
I added a test to identify the problem and the proposed patch.

fixes bug #50366

src/language/stats/frequencies.c
tests/language/stats/frequencies.at

index 675a02319aaebf1ca6f8d3b91cb323106eb1e929..305d4f1d75f4d2d4ff68a81ede9acd7a8e2fa2ff 100644 (file)
@@ -704,7 +704,7 @@ cmd_frequencies (struct lexer *lexer, struct dataset *ds)
                 }
               else if (lex_match_id (lexer, "VARIANCE"))
                 {
-                 frq.stats |= BIT_INDEX (FRQ_ST_MEAN);
+                 frq.stats |= BIT_INDEX (FRQ_ST_VARIANCE);
                  frq.n_stats++;
                 }
               else if (lex_match_id (lexer, "KURTOSIS"))
index 7c55110c967adc581e852049890f53bf5bb1ed94..e90d2d0ad0e7aed7dca84d0161968d428561cf79 100644 (file)
@@ -641,7 +641,36 @@ 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