Statistics for Type Checking and Whole-program Inference for Value Range Analysis