add mean-size hierarchical sampling in python