def lin_interp(x, x_min=0, x_max=1, y_min=0, y_max=1):
    """Lineary interpolates x from the range [x_min, xmax] to the range [y_min, y_max]."""
    return (x - x_min) * (y_max - y_min) / (x_max - x_min) + y_min