def correlation(list1, list2):
    """Calculates correlation for the given lists"""
    n = len(list1)
    sum_xy = sum([x * y for x, y in zip(list1, list2)])
    sum_x = sum(list1)
    sum_y = sum(list2)
    sum_x2 = sum([x**2 for x in list1])
    sum_y2 = sum([y**2 for y in list2])

    corr = ((n * sum_xy) - (sum_x * sum_y)) / ((n * sum_x2 - (sum_x)**2) * (n * sum_y2 - (sum_y)**2))**0.5

    return corr