def wgtd_avg(lines):
    """
    Returns the weighted average of a set of line coefficients
    """
    avg_coeffs = [0,0,0]
    i = 0
    n = len(lines)
    # Weighted average of line coefficients to get smoothed lane lines
    for line in lines:
        i += 1
        avg_coeffs = avg_coeffs + (i * line.coeffs / ((n**2 + n) / 2))

    return avg_coeffs