python - TypeError:尝试运行函数时无法解压不可迭代的 NoneType 对象
问题描述
我在代码的最后一行收到“TypeError: cannot unpack non-iterable NoneType object”的错误。你能帮我解决这个问题吗?
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)
解决方案
推荐阅读
- r - 在不同列中使用 R 将数据表中的零值替换为小随机数
- testng - 框架 - 使用 GEB 的 TestNg
- swift - 在 SwiftUI (Xcode 12) 中折叠侧边栏
- typescript - 创建一个包含类的所有静态属性的映射类型
- python-3.x - Pandas Dataframe 用 0.0 初始化并完成每个组
- java - 如果 autoStartup 设置为 false,如何手动启动 Spring Cloud Stream Binders
- python - 非数字字符的fail2ban模式与数字输入匹配
- python - Django Auth 用户和自定义用户
- c# - 无需打开即可将 XFA 文件打印为 PDF
- node.js - NodeJS 502.3 CGI 超时