贝尔曼公式
Calculating return
- Direct calculate
- Bootstrapping (returns rely on each other)
Bellman equation
- Calculate returns in bootstrapping
- Matrix-vector form is expected
State value
At(St)=Rt+1,St+1,At+1(St+1)=Rt+2,St+2,…
Gt=Rt+1+γRt+2+γ2Rt+3+…
vπ(s)=E[Gt|St=s], can also be expressed as v(s,π)
- It is a function of s .
- It is based on the policy \pi .
Deriving the Bellman equation
Gt=Rt+1+γGt+1,vπ(s)=E[Gt|St=s]=E[Rt+1|St=s]+γE[Gt+1|St=s](1)(2)
E[Rt+1|St=s]=Σaπ(a|s)E[Rt+1|St=s,At=a]=Σaπ(a|s)Σrp(r|s,a)r(3)(4)
E[Gt+1|St=s]=Σs′E[Gt+1|St+1=s′]p(s′|s)=Σs′vπ(s′)p(s′|s)=Σs′vπ(s′)Σap(s′|s,a)π(a|s)(5)(6)(7)
Therefore, we have
vπ(s)=Σaπ(a|s)[Σrp(r|s,a)r+γΣs′p(s′|s,a)vπ(s′)],∀s∈S.
- 贝尔曼公式使用n个式子求解,一般只写上述这一个式子
- 贝尔曼公式依赖于policy
- 后面几个章节都默认已知dynamic model(environment model),对于未知的model会在未来学习
Rewrite the Bellman equation as
vπ(s)=rπ(s)+γΣs′pπ(s′|s)vπ(s′)
Add the index
vπ(si)=rπ(si)+γΣsjpπ(sj|si)vπ(sj)
⎡⎢
⎢
⎢
⎢⎣vπ(s1)vπ(s2)vπ(s3)vπ(s4)⎤⎥
⎥
⎥
⎥⎦vπ=⎡⎢
⎢
⎢
⎢⎣rπ(s1)rπ(s2)rπ(s3)rπ(s4)⎤⎥
⎥
⎥
⎥⎦rπ+γ⎡⎢
⎢
⎢
⎢⎣pπ(s1|s1)pπ(s2|s1)pπ(s3|s1)pπ(s4|s1)pπ(s1|s2)pπ(s2|s2)pπ(s3|s2)pπ(s4|s2)pπ(s1|s3)pπ(s2|s3)pπ(s3|s3)pπ(s4|s3)pπ(s1|s4)pπ(s2|s4)pπ(s3|s4)pπ(s4|s4)⎤⎥
⎥
⎥
⎥⎦Pπ⎡⎢
⎢
⎢
⎢⎣vπ(s1)vπ(s2)vπ(s3)vπ(s4)⎤⎥
⎥
⎥
⎥⎦vπ
vπ=(I−γPπ)−1rπ
iterative solution
vk+1=rπ+γPπvk,vk→vπ=(I−γPπ)−1rπ,k→∞
证明方法:定义 v_k 和 v_\pi 的差
Action value
qπ(s,a)=E[Gt|St=s,At=a]
在s状态进行a动作
- a function of the state-action pair (s, a)
- depends on \pi
Relation to state value
E[Gt|St=s]vπ(s)=ΣaE[Gt|St=s,At=a]qπ(s,a)π(a|s)
Compare state value (v_ \pi) and action value(q_ \pi) , we have
qπ(s,a)=Σrp(r|s,a)r+γΣs′p(s′|s,a)vπ(s′)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人