Adaptive Sampling Code and Specs