| import random | |
| import math | |
| def map_to_random_milestone(num): | |
| """ | |
| Maps a number to a randomly selected milestone integer (multiples of 10). | |
| The milestone is randomly sampled from [ceiling to next 10, ceiling of 2*num to next 10]. | |
| Args: | |
| num: Input number (float or int) | |
| Returns: | |
| A randomly selected milestone integer ending with 0 | |
| """ | |
| # Find the smallest milestone (multiple of 10) larger than num | |
| min_milestone = math.ceil(num / 10) * 10 | |
| # Find the smallest milestone larger than 2 * num | |
| max_milestone = math.ceil(2 * num / 10) * 10 | |
| # Generate all possible milestones in the range | |
| milestones = list(range(min_milestone, max_milestone + 10, 10)) | |
| # Randomly select one milestone | |
| return random.choice(milestones) |