Author: araujo Date: Tue Nov 24 02:30:59 2015 New Revision: 291231 URL: https://svnweb.freebsd.org/changeset/base/291231
Log: Compute the median of the data set as the midpoint between the two middle values when the data set has an even number of elements. PR: 201582 Submitted by: Marcus Reid <mar...@blazingdot.com> Reviewed by: imp Approved by: bapt (mentor) Modified: head/usr.bin/ministat/ministat.c Modified: head/usr.bin/ministat/ministat.c ============================================================================== --- head/usr.bin/ministat/ministat.c Tue Nov 24 02:27:59 2015 (r291230) +++ head/usr.bin/ministat/ministat.c Tue Nov 24 02:30:59 2015 (r291231) @@ -192,8 +192,10 @@ Avg(struct dataset *ds) static double Median(struct dataset *ds) { - - return (ds->points[ds->n / 2]); + if ((ds->n % 2) == 0) + return ((ds->points[ds->n / 2] + (ds->points[(ds->n / 2) - 1])) / 2); + else + return (ds->points[ds->n / 2]); } static double _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"