added tolerance calculation for degree and within-degree sampling