Вывод уравнения Беллмана в обучении усилению


Ответы:


7

Это ответ для всех, кто задается вопросом о чистой, структурированной математике, стоящей за ней (т.е. если вы принадлежите к группе людей, которые знают, что такое случайная переменная, и что вы должны показать или предположить, что случайная переменная имеет плотность, то это ответ для вас ;-)):

Прежде всего нам нужно иметь, чтобы у Марковского процесса принятия решений было только конечное число L 1L1 -град, т.е. нам нужно, чтобы существовал конечный набор EE плотностей, каждая из которых принадлежит L 1L1 переменным, т.е. R x e ( x ) d x < Rxe(x)dx< для всех e EeE и отображения F : A × S E,F:A×SE такого что p ( r t | a t , s t )= F ( a t , s t ) ( r t )

p(rt|at,st)=F(at,st)(rt)
(т.Е. Вавтоматах за МДП может быть бесконечно много состояний, но существует только конечное число L 1L1 -направленных распределений, связанных с возможно бесконечными переходами между состояниями)

Теорема 1 : Пусть X L 1 ( Ω )XL1(Ω) (т. Е. Интегрируемая вещественная случайная величина) и пусть YY - другая случайная величина такая, что X , YX,Y имеют общую плотность, тогда E [ X | Y = y ] = R x p ( x | y ) d x

E[X|Y=y]=Rxp(x|y)dx

Доказательство : по существу доказано здесь Стефаном Хансеном.

Теорема 2 : Пусть X L 1 ( Ω ),XL1(Ω) и пусть Y , ZY,Z - другие случайные величины, такие что X , Y , ZX,Y,Z имеют общую плотность, тогда E [ X | Y = y ] = Z p ( z | y ) E [ X | Y = y , Z = z ] d z,

E[X|Y=y]=Zp(z|y)E[X|Y=y,Z=z]dz
где ZZэто диапазон ZZ .

Доказательство : E [ X | Y = y ]= R x p ( x | y ) d x    (тм. 1)= R x p ( x , y )p ( y ) dx= R x Z p ( x , y , z ) d zp ( y ) dx= ZR x p ( x , y , z )p ( y ) dxdz= ZR x p ( x | y , z ) p ( z | y ) d x d z= Z p ( z | y ) R x p ( x | y , z ) d x d z= Z p ( z | y ) E [ X | Y = y , Z = z ] d z    (тм. 1)

E[X|Y=y]=Rxp(x|y)dx    (by Thm. 1)=Rxp(x,y)p(y)dx=RxZp(x,y,z)dzp(y)dx=ZRxp(x,y,z)p(y)dxdz=ZRxp(x|y,z)p(z|y)dxdz=Zp(z|y)Rxp(x|y,z)dxdz=Zp(z|y)E[X|Y=y,Z=z]dz    (by Thm. 1)

Положим G t = k = 0 γ k R t + kGt=k=0γkRt+k и положим G ( K ) t = K k = 0 γ k R t + k,G(K)t=Kk=0γkRt+k тогда можно показать (используя тот факт, что MDP имеет только конечное число L 1L1 ), что G ( K ) tG(K)t сходится и что поскольку функция k = 0 γ k |Rt+k|k=0γk|Rt+k| is still in L1(Ω)L1(Ω) (i.e. integrable) one can also show (by using the usual combination of the theorems of monotone convergence and then dominated convergence on the defining equations for [the factorizations of] the conditional expectation) that limKE[G(K)t|St=st]=E[Gt|St=st]

limKE[G(K)t|St=st]=E[Gt|St=st]
Now one shows that E[G(K)t|St=st]=E[Rt|St=st]+γSp(st+1|st)E[G(K1)t+1|St+1=st+1]dst+1
E[G(K)t|St=st]=E[Rt|St=st]+γSp(st+1|st)E[G(K1)t+1|St+1=st+1]dst+1
using G(K)t=Rt+γG(K1)t+1G(K)t=Rt+γG(K1)t+1, Thm. 2 above then Thm. 1 on E[G(K1)t+1|St+1=s,St=st]E[G(K1)t+1|St+1=s,St=st] and then using a straightforward marginalization war, one shows that p(rq|st+1,st)=p(rq|st+1)p(rq|st+1,st)=p(rq|st+1) for all qt+1qt+1. Now we need to apply the limit KK to both sides of the equation. In order to pull the limit into the integral over the state space SS we need to make some additional assumptions:

Either the state space is finite (then S=SS=S and the sum is finite) or all the rewards are all positive (then we use monotone convergence) or all the rewards are negative (then we put a minus sign in front of the equation and use monotone convergence again) or all the rewards are bounded (then we use dominated convergence). Then (by applying limKlimK to both sides of the partial / finite Bellman equation above) we obtain

E[Gt|St=st]=E[G(K)t|St=st]=E[Rt|St=st]+γSp(st+1|st)E[Gt+1|St+1=st+1]dst+1

E[Gt|St=st]=E[G(K)t|St=st]=E[Rt|St=st]+γSp(st+1|st)E[Gt+1|St+1=st+1]dst+1

and then the rest is usual density manipulation.

REMARK: Even in very simple tasks the state space can be infinite! One example would be the 'balancing a pole'-task. The state is essentially the angle of the pole (a value in [0,2π)[0,2π), an uncountably infinite set!)

REMARK: People might comment 'dough, this proof can be shortened much more if you just use the density of GtGt directly and show that p(gt+1|st+1,st)=p(gt+1|st+1)p(gt+1|st+1,st)=p(gt+1|st+1)' ... BUT ... my questions would be:

  1. How come that you even know that Gt+1Gt+1 has a density?
  2. How come that you even know that Gt+1Gt+1 has a common density together with St+1,StSt+1,St?
  3. How do you infer that p(gt+1|st+1,st)=p(gt+1|st+1)p(gt+1|st+1,st)=p(gt+1|st+1)? This is not only the Markov property: The Markov property only tells you something about the marginal distributions but these do not necessarily determine the whole distribution, see e.g. multivariate Gaussians!

10

Let total sum of discounted rewards after time tt be:
Gt=Rt+1+γRt+2+γ2Rt+3+...Gt=Rt+1+γRt+2+γ2Rt+3+...

Utility value of starting in state,ss at time,tt is equivalent to expected sum of
discounted rewards RR of executing policy ππ starting from state ss onwards.
Uπ(St=s)=Eπ[Gt|St=s]Uπ(St=s)=Eπ[Gt|St=s]
=Eπ[(Rt+1+γRt+2+γ2Rt+3+...)|St=s]=Eπ[(Rt+1+γRt+2+γ2Rt+3+...)|St=s] By definition of GtGt
=Eπ[(Rt+1+γ(Rt+2+γRt+3+...))|St=s]=Eπ[(Rt+1+γ(Rt+2+γRt+3+...))|St=s]
=Eπ[(Rt+1+γ(Gt+1))|St=s]=Eπ[(Rt+1+γ(Gt+1))|St=s]
=Eπ[Rt+1|St=s]+γEπ[Gt+1|St=s]=Eπ[Rt+1|St=s]+γEπ[Gt+1|St=s] By law of linearity
=Eπ[Rt+1|St=s]+γEπ[Eπ(Gt+1|St+1=s)|St=s]=Eπ[Rt+1|St=s]+γEπ[Eπ(Gt+1|St+1=s)|St=s] By law of Total Expectation
=Eπ[Rt+1|St=s]+γEπ[Uπ(St+1=s)|St=s]=Eπ[Rt+1|St=s]+γEπ[Uπ(St+1=s)|St=s] By definition of UπUπ
=Eπ[Rt+1+γUπ(St+1=s)|St=s]=Eπ[Rt+1+γUπ(St+1=s)|St=s] By law of linearity

Assuming that the process satisfies Markov Property:
Probability PrPr of ending up in state ss having started from state ss and taken action aa ,
Pr(s|s,a)=Pr(St+1=s,St=s,At=a)Pr(s|s,a)=Pr(St+1=s,St=s,At=a) and
Reward RR of ending up in state ss having started from state ss and taken action aa,
R(s,a,s)=[Rt+1|St=s,At=a,St+1=s]R(s,a,s)=[Rt+1|St=s,At=a,St+1=s]

Therefore we can re-write above utility equation as,
=aπ(a|s)sPr(s|s,a)[R(s,a,s)+γUπ(St+1=s)]=aπ(a|s)sPr(s|s,a)[R(s,a,s)+γUπ(St+1=s)]

Where; π(a|s)π(a|s) : Probability of taking action aa when in state ss for a stochastic policy. For deterministic policy, aπ(a|s)=1aπ(a|s)=1


Just a few notes: The sum over ππ equals to 1 even in a stochastic policy, but in a deterministic policy, there is just one action that receives the full weight (ie, π(a|s)=1π(a|s)=1 and the rest receive 0 weight, so that term is removed from the equation. Also in the line you used the law of total expectation, the order of the condtionals is reversed
Gilad Peleg

1
I am pretty sure that this answer is incorrect: Let us follow the equations just until the line involving the law of total expectation. Then the left hand side does not depend on ss while the right hand side does... I.e. if the equations are correct then for which ss are they correct? You must have some kind of integral over ss already at that stage. The reason is probably your misunderstanding of the difference of E[X|Y]E[X|Y] (a random variable) vs. its factorization E[X|Y=y]E[X|Y=y] (a deterministic function!)...
Fabian Werner

@FabianWerner I agree this is not correct. The answer from Jie Shi is the right answer.
teucer

@teucer This answer can be fixed because there is just missing some "symmetrization", i.e. E[A|C=c]=range(B)p(b|c)E[A|B=b,C=c]dPB(b)E[A|C=c]=range(B)p(b|c)E[A|B=b,C=c]dPB(b) but still, the question is the same as in Jie Shis answer: Why is E[Gt+1|St+1=st+1,St=st]=E[Gt+1|St+1=st+1]E[Gt+1|St+1=st+1,St=st]=E[Gt+1|St+1=st+1]? This is not only the Markov property because Gt+1Gt+1 is a really complicated RV: Does it even converge? If so, where? What is the common density p(gt+1,st+1,st)p(gt+1,st+1,st)? We only know this expression for finite sums (complicated convolution) but for the infinite case?
Fabian Werner

@FabianWerner not sure if I can answer all the questions. Below some pointers. For the convergence of the Gt+1Gt+1, given that it is the sum of discounted rewards, it is reasonable to assume that the series converges (discounting factor is <1<1 and to where it converges does not really matter). I don't get the concern with the density (one can always define a joint density as long as we have random variables), it only matters if it is well defined and in that case it is.
teucer

8

Here is my proof. It is based on the manipulation of conditional distributions, which makes it easier to follow. Hope this one helps you. vπ(s)=E[Gt|St=s]=E[Rt+1+γGt+1|St=s]=srgt+1ap(s,r,gt+1,a|s)(r+γgt+1)=ap(a|s)srgt+1p(s,r,gt+1|a,s)(r+γgt+1)=ap(a|s)srgt+1p(s,r|a,s)p(gt+1|s,r,a,s)(r+γgt+1)Note that p(gt+1|s,r,a,s)=p(gt+1|s) by assumption of MDP=ap(a|s)srp(s,r|a,s)gt+1p(gt+1|s)(r+γgt+1)=ap(a|s)srp(s,r|a,s)(r+γgt+1p(gt+1|s)gt+1)=ap(a|s)srp(s,r|a,s)(r+γvπ(s))

vπ(s)=E[Gt|St=s]=E[Rt+1+γGt+1|St=s]=srgt+1ap(s,r,gt+1,a|s)(r+γgt+1)=ap(a|s)srgt+1p(s,r,gt+1|a,s)(r+γgt+1)=ap(a|s)srgt+1p(s,r|a,s)p(gt+1|s,r,a,s)(r+γgt+1)Note that p(gt+1|s,r,a,s)=p(gt+1|s) by assumption of MDP=ap(a|s)srp(s,r|a,s)gt+1p(gt+1|s)(r+γgt+1)=ap(a|s)srp(s,r|a,s)(r+γgt+1p(gt+1|s)gt+1)=ap(a|s)srp(s,r|a,s)(r+γvπ(s))
This is the famous Bellman equation.


Do you mind explaining this comment 'Note that ...' a little more? Why do these random variables Gt+1Gt+1 and the state and action variables even have a common density? If so, why do you know this property that you are using? I can see that it is true for a finite sum but if the random variable is a limit... ???
Fabian Werner

To Fabian: First let's recall what is Gt+1Gt+1. Gt+1=Rt+2+Rt+3+Gt+1=Rt+2+Rt+3+. Note that Rt+2Rt+2 only directly depends on St+1St+1 and At+1At+1 since p(s,r|s,a)p(s,r|s,a) captures all the transition information of a MDP (More precisely, Rt+2Rt+2 is independent of all states, actions, and rewards before time t+1t+1 given St+1St+1 and At+1At+1). Similarly, Rt+3Rt+3 only depends on St+2St+2 and At+2At+2. As a result, Gt+1Gt+1 is independent of StSt, AtAt, and RtRt given St+1St+1, which explains that line.
Jie Shi

Sorry, that only 'motivates' it, it doesn't actually explain anything. For example: What is the density of Gt+1Gt+1? Why are you sure that p(gt+1|st+1,st)=p(gt+1|st+1)p(gt+1|st+1,st)=p(gt+1|st+1)? Why do these random variables even have a common density? You know that a sum transforms into a convolution in densities so what... Gt+1Gt+1 should have an infinite amount of integrals in the density??? There is absolutely no candidate for the density!
Fabian Werner

To Fabian: I do not get your question. 1. You want the exact form of the marginal distribution p(gt+1)p(gt+1)? I do not know it and we do not need it in this proof. 2. why p(gt+1|st+1,st)=p(gt+1|st+1)p(gt+1|st+1,st)=p(gt+1|st+1)? Because as I mentioned earlier gt+1gt+1 and stst are independent given st+1st+1. 3. What do you mean by "common density"? You mean joint distribution? You want to know why these random variables have a joint distribution? All random variables in this universe can have a joint distribution. If this is your question, I would suggest you find a probability theory book and read it.
Jie Shi


2

What's with the following approach?

vπ(s)=Eπ[GtSt=s]=Eπ[Rt+1+γGt+1St=s]=aπ(as)srp(s,rs,a)Eπ[Rt+1+γGt+1St=s,At+1=a,St+1=s,Rt+1=r]=aπ(as)s,rp(s,rs,a)[r+γvπ(s)].

vπ(s)=Eπ[GtSt=s]=Eπ[Rt+1+γGt+1St=s]=aπ(as)srp(s,rs,a)Eπ[Rt+1+γGt+1St=s,At+1=a,St+1=s,Rt+1=r]=aπ(as)s,rp(s,rs,a)[r+γvπ(s)].

The sums are introduced in order to retrieve aa, ss and rr from ss. After all, the possible actions and possible next states can be . With these extra conditions, the linearity of the expectation leads to the result almost directly.

I am not sure how rigorous my argument is mathematically, though. I am open for improvements.


The last line only works because of the MDP property.
teucer

2

This is just a comment/addition to the accepted answer.

I was confused at the line where law of total expectation is being applied. I don't think the main form of law of total expectation can help here. A variant of that is in fact needed here.

If X,Y,ZX,Y,Z are random variables and assuming all the expectation exists, then the following identity holds:

E[X|Y]=E[E[X|Y,Z]|Y]E[X|Y]=E[E[X|Y,Z]|Y]

In this case, X=Gt+1X=Gt+1, Y=StY=St and Z=St+1Z=St+1. Then

E[Gt+1|St=s]=E[E[Gt+1|St=s,St+1=s|St=s]E[Gt+1|St=s]=E[E[Gt+1|St=s,St+1=s|St=s], which by Markov property eqauls to E[E[Gt+1|St+1=s]|St=s]E[E[Gt+1|St+1=s]|St=s]

From there, one could follow the rest of the proof from the answer.


1
Welcome to CV! Please use the answers only for answering the question. Once you have enough reputation (50), you can add comments.
Frans Rodenburg

Thank you. Yes, since I could not comment due to not having enough reputation, I thought it might be useful to add the explanation to the answers. But I will keep that in mind.
Mehdi Golari

I upvoted but still, this answer is missing details: Even if E[X|Y]E[X|Y] satisfies this crazy relationship then nobody guarantees that this is true for the factorizations of the conditional expectations as well! I.e. as in the case with the answer of Ntabgoba: The left hand side does not depend on ss while the right hand side does. This equation cannot be correct!
Fabian Werner

1

Eπ()Eπ() usually denotes the expectation assuming the agent follows policy ππ. In this case π(a|s)π(a|s) seems non-deterministic, i.e. returns the probability that the agent takes action aa when in state ss.

It looks like rr, lower-case, is replacing Rt+1Rt+1, a random variable. The second expectation replaces the infinite sum, to reflect the assumption that we continue to follow ππ for all future tt. s,rrp(s,r|s,a)s,rrp(s',r|s,a) is then the expected immediate reward on the next time step; The second expectation—which becomes vπvπ—is the expected value of the next state, weighted by the probability of winding up in state ss having taken aa from ss.

Thus, the expectation accounts for the policy probability as well as the transition and reward functions, here expressed together as p(s,r|s,a)p(s,r|s,a).


Thanks. Yes, what you mentioned about π(a|s)π(a|s) is correct (it's the probability of the agent taking action aa when in state ss).
Amelio Vazquez-Reina

What I don't follow is what terms exactly get expanded into what terms in the second step (I'm familiar with probability factorization and marginalization, but not so much with RL). Is RtRt the term being expanded? I.e. what exactly in the previous step equals what exactly in the next step?
Amelio Vazquez-Reina

1
It looks like rr, lower-case, is replacing Rt+1Rt+1, a random variable, and the second expectation replaces the infinite sum (probably to reflect the assumption that we continue to follow ππ for all future tt). Σp(s,r|s,a)rΣp(s,r|s,a)r is then the expected immediate reward on the next time step, and the second expectation—which becomes vπvπ—is the expected value of the next state, weighted by the probability of winding up in state ss having taken aa from ss.
Sean Easter

1

even though the correct answer has already been given and some time has passed, I thought the following step by step guide might be useful:
By linearity of the Expected Value we can split E[Rt+1+γE[Gt+1|St=s]]E[Rt+1+γE[Gt+1|St=s]] into E[Rt+1|St=s]E[Rt+1|St=s] and γE[Gt+1|St=s]γE[Gt+1|St=s].
I will outline the steps only for the first part, as the second part follows by the same steps combined with the Law of Total Expectation.

E[Rt+1|St=s]=rrP[Rt+1=r|St=s]=arrP[Rt+1=r,At=a|St=s](III)=arrP[Rt+1=r|At=a,St=s]P[At=a|St=s]=sarrP[St+1=s,Rt+1=r|At=a,St=s]P[At=a|St=s]=aπ(a|s)s,rp(s,r|s,a)r

E[Rt+1|St=s]=rrP[Rt+1=r|St=s]=arrP[Rt+1=r,At=a|St=s](III)=arrP[Rt+1=r|At=a,St=s]P[At=a|St=s]=sarrP[St+1=s,Rt+1=r|At=a,St=s]P[At=a|St=s]=aπ(a|s)s,rp(s,r|s,a)r

Whereas (III) follows form: P[A,B|C]=P[A,B,C]P[C]=P[A,B,C]P[C]P[B,C]P[B,C]=P[A,B,C]P[B,C]P[B,C]P[C]=P[A|B,C]P[B|C]

P[A,B|C]=P[A,B,C]P[C]=P[A,B,C]P[C]P[B,C]P[B,C]=P[A,B,C]P[B,C]P[B,C]P[C]=P[A|B,C]P[B|C]


1

I know there is already an accepted answer, but I wish to provide a probably more concrete derivation. I would also like to mention that although @Jie Shi trick somewhat makes sense, but it makes me feel very uncomfortable:(. We need to consider the time dimension to make this work. And it is important to note that, the expectation is actually taken over the entire infinite horizon, rather than just over ss and ss. Let assume we start from t=0t=0 (in fact, the derivation is the same regardless of the starting time; I do not want to contaminate the equations with another subscript kk) vπ(s0)=Eπ[G0|s0]G0=T1t=0γtRt+1Eπ[G0|s0]=a0π(a0|s0)a1,...aTs1,...sTr1,...rT(T1t=0π(at+1|st+1)p(st+1,rt+1|st,at)×(T1t=0γtrt+1))=a0π(a0|s0)a1,...aTs1,...sTr1,...rT(T1t=0π(at+1|st+1)p(st+1,rt+1|st,at)×(r1+γT2t=0γtrt+2))

vπ(s0)G0Eπ[G0|s0]=Eπ[G0|s0]=t=0T1γtRt+1=a0π(a0|s0)a1,...aTs1,...sTr1,...rT(t=0T1π(at+1|st+1)p(st+1,rt+1|st,at)×(t=0T1γtrt+1))=a0π(a0|s0)a1,...aTs1,...sTr1,...rT(t=0T1π(at+1|st+1)p(st+1,rt+1|st,at)×(r1+γt=0T2γtrt+2))
NOTED THAT THE ABOVE EQUATION HOLDS EVEN IF TT, IN FACT IT WILL BE TRUE UNTIL THE END OF UNIVERSE (maybe be a bit exaggerated :) )
At this stage, I believe most of us should already have in mind how the above leads to the final expression--we just need to apply sum-product rule(abcabcaabbccabcabcaabbcc) painstakingly. Let us apply the law of linearity of Expectation to each term inside the (r1+γT2t=0γtrt+2)(r1+γT2t=0γtrt+2)

Part 1 a0π(a0|s0)a1,...aTs1,...sTr1,...rT(T1t=0π(at+1|st+1)p(st+1,rt+1|st,at)×r1)

a0π(a0|s0)a1,...aTs1,...sTr1,...rT(t=0T1π(at+1|st+1)p(st+1,rt+1|st,at)×r1)

Well this is rather trivial, all probabilities disappear (actually sum to 1) except those related to r1r1. Therefore, we have a0π(a0|s0)s1,r1p(s1,r1|s0,a0)×r1

a0π(a0|s0)s1,r1p(s1,r1|s0,a0)×r1

Part 2
Guess what, this part is even more trivial--it only involves rearranging the sequence of summations. a0π(a0|s0)a1,...aTs1,...sTr1,...rT(T1t=0π(at+1|st+1)p(st+1,rt+1|st,at))=a0π(a0|s0)s1,r1p(s1,r1|s0,a0)(a1π(a1|s1)a2,...aTs2,...sTr2,...rT(T2t=0π(at+2|st+2)p(st+2,rt+2|st+1,at+1)))

a0π(a0|s0)a1,...aTs1,...sTr1,...rT(t=0T1π(at+1|st+1)p(st+1,rt+1|st,at))=a0π(a0|s0)s1,r1p(s1,r1|s0,a0)(a1π(a1|s1)a2,...aTs2,...sTr2,...rT(t=0T2π(at+2|st+2)p(st+2,rt+2|st+1,at+1)))

And Eureka!! we recover a recursive pattern in side the big parentheses. Let us combine it with γT2t=0γtrt+2γT2t=0γtrt+2, and we obtain vπ(s1)=Eπ[G1|s1]vπ(s1)=Eπ[G1|s1] γEπ[G1|s1]=a1π(a1|s1)a2,...aTs2,...sTr2,...rT(T2t=0π(at+2|st+2)p(st+2,rt+2|st+1,at+1))(γT2t=0γtrt+2)

γEπ[G1|s1]=a1π(a1|s1)a2,...aTs2,...sTr2,...rT(t=0T2π(at+2|st+2)p(st+2,rt+2|st+1,at+1))(γt=0T2γtrt+2)

and part 2 becomes a0π(a0|s0)s1,r1p(s1,r1|s0,a0)×γvπ(s1)
a0π(a0|s0)s1,r1p(s1,r1|s0,a0)×γvπ(s1)

Part 1 + Part 2 vπ(s0)=a0π(a0|s0)s1,r1p(s1,r1|s0,a0)×(r1+γvπ(s1))

vπ(s0)=a0π(a0|s0)s1,r1p(s1,r1|s0,a0)×(r1+γvπ(s1))

And now if we can tuck in the time dimension and recover the general recursive formulae

vπ(s)=aπ(a|s)s,rp(s,r|s,a)×(r+γvπ(s))

vπ(s)=aπ(a|s)s,rp(s,r|s,a)×(r+γvπ(s))

Final confession, I laughed when I saw people above mention the use of law of total expectation. So here I am


Erm... what is the symbol 'a0,...,aa0,...,a' supposed to mean? There is no aa...
Fabian Werner

Another question: Why is the very first equation true? I know E[f(X)|Y=y]=Xf(x)p(x|y)dxE[f(X)|Y=y]=Xf(x)p(x|y)dx but in our case, XX would be an infinite sequence of random variables (R0,R1,R2,........)(R0,R1,R2,........) so we would need to compute the density of this variable (consisting of an infinite amount of variables of which we know the density) together with something else (namely the state)... how exactly do you du that? I.e. what is p(r0,r1,....)p(r0,r1,....)?
Fabian Werner

@FabianWerner. Take a deep breath to calm your brain first:). Let me answer your first question. a0,...,aa0a1,...,aa0,...,aa0a1,...,a. If you recall the definition of the value function, it is actually a summation of discounted future rewards. If we consider an infinite horizon for our future rewards, we then need to sum infinite number of times. A reward is result of taking an action from a state, since there is an infinite number of rewards, there should be an infinite number of actions, hence aa.
Karlsson Yu

1
let us assume that I agree that there is some weird aa (which I still doubt, usually, students in the very first semester in math tend to confuse the limit with some construction that actually involves an infinite element)... I still have one simple question: how is “a1...aa1...a defined? I know what this expression is supposed to mean with a finite amount of sums... but infinitely many of them? What do you understand that this expression does?
Fabian Werner

1
internet. Could you refer me to a page or any place that defines your expression? If not then you actually defined something new and there is no point in discussing that because it is just a symbol that you made up (but there is no meaning behind it)... you agree that we are only able to discuss about the symbol if we both know what it means, right? So, I do not know what it means, please explain...
Fabian Werner

1

There are already a great many answers to this question, but most involve few words describing what is going on in the manipulations. I'm going to answer it using way more words, I think. To start,

GtTk=t+1γkt1Rk

Gtk=t+1Tγkt1Rk

is defined in equation 3.11 of Sutton and Barto, with a constant discount factor 0γ10γ1 and we can have T=T= or γ=1γ=1, but not both. Since the rewards, RkRk, are random variables, so is GtGt as it is merely a linear combination of random variables.

vπ(s)Eπ[GtSt=s]=Eπ[Rt+1+γGt+1St=s]=Eπ[Rt+1|St=s]+γEπ[Gt+1|St=s]

vπ(s)Eπ[GtSt=s]=Eπ[Rt+1+γGt+1St=s]=Eπ[Rt+1|St=s]+γEπ[Gt+1|St=s]

That last line follows from the linearity of expectation values. Rt+1Rt+1 is the reward the agent gains after taking action at time step tt. For simplicity, I assume that it can take on a finite number of values rRrR.

Work on the first term. In words, I need to compute the expectation values of Rt+1Rt+1 given that we know that the current state is ss. The formula for this is

Eπ[Rt+1|St=s]=rRrp(r|s).

Eπ[Rt+1|St=s]=rRrp(r|s).

In other words the probability of the appearance of reward rr is conditioned on the state ss; different states may have different rewards. This p(r|s)p(r|s) distribution is a marginal distribution of a distribution that also contained the variables aa and ss, the action taken at time tt and the state at time t+1t+1 after the action, respectively:

p(r|s)=sSaAp(s,a,r|s)=sSaAπ(a|s)p(s,r|a,s).

p(r|s)=sSaAp(s,a,r|s)=sSaAπ(a|s)p(s,r|a,s).

Where I have used π(a|s)p(a|s)π(a|s)p(a|s), following the book's convention. If that last equality is confusing, forget the sums, suppress the ss (the probability now looks like a joint probability), use the law of multiplication and finally reintroduce the condition on ss in all the new terms. It in now easy to see that the first term is

Eπ[Rt+1|St=s]=rRsSaArπ(a|s)p(s,r|a,s),

Eπ[Rt+1|St=s]=rRsSaArπ(a|s)p(s,r|a,s),

as required. On to the second term, where I assume that Gt+1Gt+1 is a random variable that takes on a finite number of values gΓgΓ. Just like the first term:

Eπ[Gt+1|St=s]=gΓgp(g|s).()

Eπ[Gt+1|St=s]=gΓgp(g|s).()

Once again, I "un-marginalize" the probability distribution by writing (law of multiplication again)

p(g|s)=rRsSaAp(s,r,a,g|s)=rRsSaAp(g|s,r,a,s)p(s,r,a|s)=rRsSaAp(g|s,r,a,s)p(s,r|a,s)π(a|s)=rRsSaAp(g|s,r,a,s)p(s,r|a,s)π(a|s)=rRsSaAp(g|s)p(s,r|a,s)π(a|s)()

p(g|s)=rRsSaAp(s,r,a,g|s)=rRsSaAp(g|s,r,a,s)p(s,r,a|s)=rRsSaAp(g|s,r,a,s)p(s,r|a,s)π(a|s)=rRsSaAp(g|s,r,a,s)p(s,r|a,s)π(a|s)=rRsSaAp(g|s)p(s,r|a,s)π(a|s)()

The last line in there follows from the Markovian property. Remember that Gt+1Gt+1 is the sum of all the future (discounted) rewards that the agent receives after state ss. The Markovian property is that the process is memory-less with regards to previous states, actions and rewards. Future actions (and the rewards they reap) depend only on the state in which the action is taken, so p(g|s,r,a,s)=p(g|s)p(g|s,r,a,s)=p(g|s), by assumption. Ok, so the second term in the proof is now

γEπ[Gt+1|St=s]=γgΓrRsSaAgp(g|s)p(s,r|a,s)π(a|s)=γrRsSaAEπ[Gt+1|St+1=s]p(s,r|a,s)π(a|s)=γrRsSaAvπ(s)p(s,r|a,s)π(a|s)

γEπ[Gt+1|St=s]=γgΓrRsSaAgp(g|s)p(s,r|a,s)π(a|s)=γrRsSaAEπ[Gt+1|St+1=s]p(s,r|a,s)π(a|s)=γrRsSaAvπ(s)p(s,r|a,s)π(a|s)

as required, once again. Combining the two terms completes the proof

vπ(s)Eπ[GtSt=s]=aAπ(a|s)rRsSp(s,r|a,s)[r+γvπ(s)].

vπ(s)Eπ[GtSt=s]=aAπ(a|s)rRsSp(s,r|a,s)[r+γvπ(s)].

UPDATE

I want to address what might look like a sleight of hand in the derivation of the second term. In the equation marked with ()(), I use a term p(g|s)p(g|s) and then later in the equation marked ()() I claim that gg doesn't depend on ss, by arguing the Markovian property. So, you might say that if this is the case, then p(g|s)=p(g). But this is not true. I can take p(g|s,r,a,s)p(g|s) because the probability on the left side of that statement says that this is the probability of g conditioned on s, a, r, and s. Because we either know or assume the state s, none of the other conditionals matter, because of the Markovian property. If you do not know or assume the state s, then the future rewards (the meaning of g) will depend on which state you begin at, because that will determine (based on the policy) which state s you start at when computing g.

If that argument doesn't convince you, try to compute what p(g) is:

p(g)=sSp(g,s)=sSp(g|s)p(s)=sSp(g|s)s,a,rp(s,a,r,s)=sSp(g|s)s,a,rp(s,r|a,s)p(a,s)=sSp(s)sSp(g|s)a,rp(s,r|a,s)π(a|s)sSp(s)p(g|s)=sSp(g,s)=p(g).

As can be seen in the last line, it is not true that p(g|s)=p(g). The expected value of g depends on which state you start in (i.e. the identity of s), if you do not know or assume the state s.

Используя наш сайт, вы подтверждаете, что прочитали и поняли нашу Политику в отношении файлов cookie и Политику конфиденциальности.
Licensed under cc by-sa 3.0 with attribution required.