stats: fix handling of NaN in `min` and `max`