def simple_leastsq(x, y):
    """
    最小二乘法算法的简单实现，依赖原理为残差平方和最小。

    :param x: 要拟合数据的自变量列表 
    :param y: 要拟合数据的因变量列表
    :return: 拟合的两个参数值
    """

    meanx = sum(x) / len(x)  # 求x的平均值
    meany = sum(y) / len(y)  # 求y的平均值

    xsum = 0.0
    ysum = 0.0

    for i in range(len(x)):
        xsum += (x[i] - meanx) * (y[i] - meany)
        ysum += (x[i] - meanx) ** 2

    k = xsum / ysum
    b = meany - k * meanx

    return k, b