work on CTABLES
[pspp] / src / language / stats / kruskal-wallis.c
index ae6fffe205118decea725ed1badc9f6e17be7034..62c49e48482cd05b5b0d09d7e0f5f231b4a6a4c8 100644 (file)
@@ -137,7 +137,7 @@ kruskal_wallis_execute (const struct dataset *ds,
 
   int total_n_groups = 0.0;
 
-  struct kw *kw = xcalloc (nst->n_vars, sizeof *kw);
+  struct kw *kw = XCALLOC (nst->n_vars,  struct kw);
 
   /* If the independent variable is missing, then we ignore the case */
   input = casereader_create_filter_missing (input,
@@ -183,7 +183,7 @@ kruskal_wallis_execute (const struct dataset *ds,
          const size_t group_var_width = var_get_width (nst->indep_var);
          struct rank_entry *rank = find_rank_entry (&kw[i].map, group, group_var_width);
 
-         if ( NULL == rank)
+         if (NULL == rank)
            {
              rank = xzalloc (sizeof *rank);
              value_clone (&rank->group, group, group_var_width);
@@ -192,7 +192,7 @@ kruskal_wallis_execute (const struct dataset *ds,
                           value_hash (&rank->group, group_var_width, 0));
            }
 
-         rank->sum_of_ranks += case_data_idx (c, rank_idx)->f;
+         rank->sum_of_ranks += case_num_idx (c, rank_idx);
          rank->n += dict_get_case_weight (dict, c, &warn);
 
          /* If this assertion fires, then either the data wasn't sorted or some other
@@ -214,7 +214,7 @@ kruskal_wallis_execute (const struct dataset *ds,
 
            total_n_groups ++;
          }
-       kw[i].h *= 12 / (n * ( n + 1));
+       kw[i].h *= 12 / (n * (n + 1));
        kw[i].h -= 3 * (n + 1) ;
 
        kw[i].h /= 1 - tiebreaker/ (pow3 (n) - n);