X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fbox-whisker.c;h=53831824a09a32d0b5025607628983f7e1bba22e;hb=5d612c43713291cae1aa473ee3d31786ef6f5b99;hp=0d893cb80c14d98e4b7bf3c24c5603b4d23c5d27;hpb=d6f63e70f4ec5f70e25f8c0bb9f33f65f8dc2f34;p=pspp diff --git a/src/math/box-whisker.c b/src/math/box-whisker.c index 0d893cb80c..53831824a0 100644 --- a/src/math/box-whisker.c +++ b/src/math/box-whisker.c @@ -40,7 +40,7 @@ destroy (struct statistic *s) struct order_stats *os = &bw->parent; struct ll *ll; - for (ll = ll_head (&bw->outliers); ll != ll_null (&bw->outliers); ) + for (ll = ll_head (&bw->outliers); ll != ll_null (&bw->outliers);) { struct outlier *e = ll_data (ll, struct outlier, ll); @@ -63,20 +63,28 @@ acc (struct statistic *s, const struct ccase *cx, bool extreme; struct outlier *o; - if ( y < bw->hinges[2] + bw->step) - bw->whiskers[1] = y; + if (y > bw->hinges[2] + bw->step) /* Upper outlier */ + { + extreme = (y > bw->hinges[2] + 2 * bw->step) ; + } + + else if (y < bw->hinges[0] - bw->step) /* Lower outlier */ + { + extreme = (y < bw->hinges[0] - 2 * bw->step) ; + } - if (bw->whiskers[0] == SYSMIS || bw->hinges[0] - bw->step > y) - bw->whiskers[0] = y; + else /* Not an outlier */ + { + if (bw->whiskers[0] == SYSMIS) + bw->whiskers[0] = y; - if ( y > bw->hinges[2] + bw->step) - extreme = (y > bw->hinges[2] + 2 * bw->step) ; + if (y > bw->whiskers[1]) + bw->whiskers[1] = y; - else if (y < bw->hinges[0] - bw->step) - extreme = (y < bw->hinges[0] - 2 * bw->step) ; + return; + } - else - return; + /* y is an outlier */ o = xzalloc (sizeof *o) ; o->value = y; @@ -128,7 +136,7 @@ box_whisker_outliers (const struct box_whisker *bw) TH are the tukey hinges of the dataset. - id_idx is the index into the casereader which will be used to label + id_idx is the index into the casereader which will be used to label outliers. id_var is the variable from which that label came, or NULL */