Implement random generator.