scripts used in http://arxiv.org/abs/1405.3272