Create Random Sampling Code