code for random sampling baselines