Change stats collation for LTS to the median, thereby avoiding summing overflows.

This commit is contained in:
Herbert Wolverson
2023-11-12 21:49:53 -06:00
parent b41f786070
commit bcc306b2eb

View File

@@ -40,9 +40,11 @@ impl<
min = T::min(min, *n);
max = T::max(max, *n);
});
let length = stats.len();
let mut values = stats.to_vec();
values.sort();
let length = values.len();
let median = if length == 0 { T::zero() } else {
stats[length/2]
values[length/2]
};
Self { max, min, avg: median(stats): median }