Measuring the lack of monotonicity in functions