FREQUENCIES: Use the smallest mode if there are multiple.
[pspp] / src / language / stats / frequencies.c
index cf40446a77d5e944b8766594260d3500bf50e5e8..d20d8392c176d4827a2f4f0e28d3f4e53b73bf0f 100644 (file)
@@ -1502,21 +1502,14 @@ calc_stats (const struct frq_proc *frq, const struct var_freqs *vf,
   int most_often = -1;
   double X_mode = SYSMIS;
 
-  /* Calculate the mode. */
+  /* Calculate the mode.  If there is more than one mode, we take the
+     smallest. */
   for (f = ft->valid; f < ft->missing; f++)
-    {
-      if (most_often < f->count)
-        {
-          most_often = f->count;
-          X_mode = f->values[0].f;
-        }
-      else if (most_often == f->count)
-        {
-          /* A duplicate mode is undefined.
-             FIXME: keep track of *all* the modes. */
-          X_mode = SYSMIS;
-        }
-    }
+    if (most_often < f->count)
+      {
+        most_often = f->count;
+        X_mode = f->values[0].f;
+      }
 
   /* Calculate moments. */
   m = moments_create (MOMENT_KURTOSIS);
@@ -1613,7 +1606,7 @@ frq_stats_table_create (const struct frq_proc *frq,
                                     pc->p * 100.0));
     }
 
-  struct pivot_splits *splits = pivot_splits_create (table, PIVOT_AXIS_ROW,
+  struct pivot_splits *splits = pivot_splits_create (table, PIVOT_AXIS_COLUMN,
                                                      dict);
 
   struct frq_stats_table *fst = xmalloc (sizeof *fst);