TypeError:尝试运行函数时无法解压缩不可迭代的NoneType对象

时间:2019-02-09 00:10:08

标签: python python-3.x

我在代码的最后一行收到“ TypeError:无法解压缩不可迭代的NoneType对象”的错误。你能帮我吗?

import matplotlib.pyplot as plt

#Weights (lb)
Measured = [158, 164.2, 160.3, 159.9, 162.1, 164.6,
169.6, 167.4, 166.4, 171, 171.2, 172.6]

#time step of 1 day
time_step = 1

#kalman Gain
Kg = 4/10

def predict_using_gain_guess(updated_estimate, gain_rate):
    estimates, predictions = [updated_estimate], []

    for z in Measured:
        #predict new position based on hypothesis that we are gaining 1lb every day
        prediction_hp = updated_estimate + gain_rate*time_step

        #update filter
        updated_estimate = prediction_hp + Kg * (z - prediction_hp)

        #save
        estimates.append(updated_estimate)
        predictions.append(prediction_hp)

initial_estimate = 160
estimates, predictions = predict_using_gain_guess(
    updated_estimate=initial_estimate, gain_rate=1)

0 个答案:

没有答案