In the changed regions, the mean of 5 and 6 was calculated thanks to `stat_length=2`. In IEEE correct rounding (NumPy standard), 5.5 should round to 6, however, in the prior function the calculations were carried out and immediately *cast* into the original dtype (akin to `arr.astype(np.int32)`). The casting operation truncates like `np.floor` instead of rounding properly, resulting in systematic error in the rounded regions. It's pure luck that more didn't need to be changed; the block of 4s on the left is rounded down from 4.5 in the IEEE standard, thus truncation is equivalent there.

I believe this is the correct way to do it, but if truncating/direct casting was *desired* for some reason the previous version could be considered correct in its own way.