def poly_smooth(x: float, n: float = 3) -> float:
    """Polynomial easing of a variable in range [0, 1].

    Args:
        x (float): variable to be smoothed
        n (float, optional): polynomial degree. Defaults to 3.

    Returns:
        float: _description_
    """
    if x > 1:
        return 1
    if x < 0:
        return 0

    if x < 0.5:
        return pow(2, n - 1) * pow(x, n)

    return 1 - pow(-2 * x + 2, n) / 2