In standard property testing, the task is to distinguish between objects that have a property P and those that are epsilon-far from P, for some epsilon > 0. In this setting, it is perfectly acceptable for the tester to provide a negative answer for every input object that does not satisfy P. This implies that property testing in and of itself cannot be expected to yield any information whatsoever about the distance from the object to the property. We address this problem in this paper, restricting our attention to monotonicity testing. A function f : {1,..., n} R is at distance epsilon(f) from being monotone if it can (and must) be modified at epsilon(f)n places to become monotone. For any fixed delta > 0, we compute, with probability at least 2/3, an interval [(1/2 - delta)epsilon, epsilon] that encloses epsilon(f). The running time of our algorithm is O(epsilon(-1)(f) log log epsilon(-1)(f) log n), which is optimal within a factor of log log epsilon(-1)(f) and represents a substantial improvement over previous work. We give a second algorithm with an expected running time of O(epsilon(-1)(f) log n log log log n). Finally, we extend our results to multivariate functions. (C) 2007 Wiley Periodicals, Inc.