Check if mean is a number before calculating variance