Median Absolute Deviation (MAD)
Code
int64_t median_absolute_deviation(std::span<int32_t>&& a) {
size_t n = a.size();
int64_t median = a[n / 2];
return accumulate(begin(a), end(a), int64_t(0),
[&](const int64_t& x, const int64_t& y) { return x + abs(y - median); });
}