summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-05-13 07:40:31 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-05-13 07:40:31 +0100
commitc201cd58c24f5fe611b63cf1a71cc6953538fe96 (patch)
tree22d43a1dac55e95979b550439af7c97dd7ce9d57
parent8042c056503ccadcf588af482eef56a3bf8a4d9e (diff)
improved-median
-rw-r--r--ministat.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ministat.c b/ministat.c
index 8b29578..fee047b 100644
--- a/ministat.c
+++ b/ministat.c
@@ -188,8 +188,9 @@ Avg(struct dataset *ds)
static double
Median(struct dataset *ds)
{
+ int half = ds->n / 2;
- return (ds->points[ds->n / 2]);
+ return (ds->points[half] + ds->points[ds->n - half - 1]) / 2;
}
static double