Added functionality to create random samples.