May as well put mean_mode and variance_mode checks first in the if/else if/.../ chain, as they're cheap tests we've already done.