import math
import random


def random_joint_positions(
    number_of_fingers,
    lower_bounds=[-math.radians(30), -math.radians(60), -math.radians(100)],
    upper_bounds=[math.radians(30), math.radians(60), math.radians(2)],
):
    """Sample a random joint configuration for each finger.

    Args:
        number_of_fingers (int): specify if positions are to be sampled for
            joints of 1 finger, or 3 fingers
        lower_bounds: List of lower position bounds for upper, middle and lower
            joint of a single finger.  The same values will be used for all
            fingers if number_of_fingers > 1.  Unit: radian.
        upper_bounds: Upper position bounds of the joints.  See lower_bounds.

    Returns:
        Flat list of joint positions.
    """
    list_to_return = [
        random.uniform(lower, upper)
        for i in range(number_of_fingers)
        for lower, upper in zip(lower_bounds, upper_bounds)
    ]
    return list_to_return