Properly handle weights in Friedman test
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 23 Oct 2010 09:51:13 +0000 (11:51 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 23 Oct 2010 09:51:13 +0000 (11:51 +0200)
src/language/stats/friedman.c

index d5890e3fef737b3580f1049aa989424f55bb28e7..4a0201e6ac112b3ecfbd5bbbfc0b856424939a71 100644 (file)
@@ -157,7 +157,7 @@ friedman_execute (const struct dataset *ds,
              if ( run_length > 0)
                {
                  double t = run_length + 1;
-                 sigma_t += pow3 (t) - t;
+                 sigma_t += w * (pow3 (t) - t);
                }
              run_length = 0;
            }
@@ -166,14 +166,13 @@ friedman_execute (const struct dataset *ds,
       if ( run_length > 0)
        {
          double t = run_length + 1;
-         sigma_t += pow3 (t) - t;
+         sigma_t += w * (pow3 (t) - t );
        }
 
       qsort (row, ft->n_vars, sizeof *row, cmp_posn);
 
       for (v = 0; v < ft->n_vars; ++v)
-       fr.rank_sum[v] += row[v].x;
-
+       fr.rank_sum[v] += row[v].x * w;
     }
   casereader_destroy (input);
   free (row);