mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
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
98db8f80a7
commit
19d3ba993d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291231
@ -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