Init code for random sample