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 <marcus@blazingdot.com> Reviewed by: imp Approved by: bapt (mentor)
This commit is contained in:
parent
ba54012c27
commit
835b818769
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user