def linear_regression(x_list, y_list):
    """ Calculates slope and intercept using linear regression
    This implementation is not suited for large datasets

    Arguments:
    tuples_list -- An array of tuples containing x and y values

    Output:
    A tuple of slope and intercept values
    """
    assert len(x_list) == len(y_list), 'expected input shapes to match'
    sum_x = 0.0
    sum_y = 0.0
    sum_xy = 0.0
    sum_x_squared = 0.0
    sum_y_squared = 0.0
    count = len(x_list)
    for i in range(0, len(x_list)):
        x = x_list[i]
        y = y_list[i]
        sum_x += x
        sum_y += y
        sum_xy += x * y
        sum_x_squared += x * x
        sum_y_squared += y * y
    try:
        slope = (count * sum_xy - sum_x * sum_y) / (count * sum_x_squared -
            sum_x * sum_x)
    except ZeroDivisionError:
        return float('NaN')
    return slope
