본문 바로가기

BITS

[Reinforcement Learning in Finance] Introduction to Markov Decision Processes and Reinforcement Learning in Finance

Bellman equation and their relation to reinforcement learning Recap

- 강화학습은 각 단계에서 최적의 action을 결정하는 sequential decision making 의 environment 에서 교류하는 agent와 관련한다. 이러한 행위를 action tasks 라고 부른다. 

- 현재 environment의 상태인 State($S_t$) 에 대한정보를 받는데, 이때 environment은 복잡한 dynamics로 구성되있기 때문에,강화학습의 tasks는 planning과 forecasting을 구성해야한다.  

- 장기적인 목적을 달성하기 위해서 각 단계에서 agent는 Action($A_t$) 을 통해 environment의 state에 영향을 미치게된다. 




이러한 과정은 feedback loop을 형성한다.

- 즉, 현재 agent의 action이 다음단계의 environment를 변화시켜, 다음 단계의 행동이 바뀌게 된다. 

- 지도학습 (supervised learning) 이나 비지도학습 (unsupervised learning) 에서는 action이 언제나 동일하기 때문에, feedback loop는 SL, UL 에서는 발생하지 않는다. 

- 예를들어 비지도학습에서는 data를 cluster하는 등일텐데, 이러한 data 에서는 loop 을 통한 과정이 필요없다.


Online RL, Batch Mode(Offline) RL

- Online RL: 실시간으로 행해지는 특징(로봇청소기)

- BatchMode: 환경에 대허 on-demand access를 필요로 하지 않는대신에, states of the environment나 actions taken, rewards received 에 대한 기록을 가지고 있다. 


환경이 완벽하게 observable 하다면, 이것의 dynamics를 Markov Process로 모델화할수 있다. 

- Markov Process는 short memory로 비유할수 있다. 

- 모델의 미래 행동이 전체 history에 근거하는 것이 아니라, 현재 상태 (current state)에 근거한다. 


환경중 일부만 observable 하고 일부는 unobservable하다면, partially observed environment 로 구분한다. 

- 이러한 경우에는 dynamic latent variable models 로 모델화한다. 

- hidden Markov Models가 이에 해당한다. 


agent의 action 관련한 Markov Dynamics의 proper mathematical formalism을 Markov Decision Process (MDP) 라 부른다. 



위 그림은 Markov Decision Process를 보여주는데, 

- 파란색원은 각단계에서 (discrete time steps) System (Environment)의 state ($S_t$) 를 의미하며 각 단계는 화살표로 연결되는데, 이 화살표는 원인결과를 의미한다. (casuality relations) 각 원은 한계의 화살표로만 연결되는데 이는 전체와 상관없이 바로 이전의 상태만이 상관성을 지니는 것을 의미한다. 

- 초록색원은 agent의 actions taken ($A_t$)을 의미한다. 

- 위를 향하는 화살표는 agent의 action을 통해서 얻을수 있는 reward ($r_t$) 를 의미한다. 


수학적으로는

- $s_t \in S: S$ is a set of states(discrete or continuous)

- $a_t \in A: A$ is a set of actions(discrete or continuous)

- $p(s_{t+1}) | s_t, a_t)$ are transition probabilities

- $R: S \times A \mapsto R$ is a reward function (can depend on both state and action)

- $\gamma \in [0,1]$ is a discount factor

- Cumulative total reward: sum of whole single step rewards

 $R(s_0, a_0) + \gamma R(s_1, a_1)+ \gamma^2 R(s_2, a_2) + ... = \sum_n \gamma^n R(s_n, a_n)$

이는 MDP의 discount factor가 time value of rewards를 반영하는 것처럼, 당장 큰 reward를 받고 나중에 적은 reward를 받는것이, 지금 적은 reward를 받고, 나중에 큰 reward를 받는것보다 좋다는 것을 의미한다. 


MDP나 RL에서의 목적은 expected total cumulative reward를 최대화하는것이다.

- agent들이 각 단계에서 어떻게 행동해야하는지의 decision policy를 올바르게 설정하여 이것이 가능하게 한다. 

- 우리는 현재 시스템의 상태만 알뿐, 미래에 대해서 알지 못하지만, 모든 가능한 미래의 환경에 대한 시나리오를 고려하여 cumulative reward가 최대화 될수있도록한다. 

- $E[R(s_0, a_0) + \gamma R(s_1, a_1) + \gamma^2 R(s_2, a_2) + ... ] = E[\sum_n \gamma^n R(s_n, a_n)]$

- 주어진 policy에 대한 risk 아니라, looks only at a mean of the distribution of total reward  (평균적으로 좋은 action policy를 찾는것) 이기 때문에, risk-neutral reinforcement learning: expected cumulative reward.

- 이와 다르게 risk-sensitive reinforcement learning의 경우, look at some higher moments of the resulting distribution of cumulative rewards, in addition to looking only at its mean value as is done in a conventional risk-neutral reinforcement learning. 


Quiz: Select the correct answer

1. The goal of (risk-neutral) Reinforcement Learning is to maximize the expected total reward by choosing an optimal policy.

2. To goal of risk-sensitive Reinforcement Learning is to teach a RL agent to pick action policies that are most prone to risk of failure. Risk-sensitive RL is used e.g. by venture capitalists and other sponsors of RL research, as a quick tool to access the feasibility of new RL projects.

3. The name “Markov Processes” first historically appeared as a result of a misspelled name “Mark-Off Processes” that was previously used for random processes that describe learning in certain types of video games, but has become a standard terminology since then.

4. The goal of (risk-neutral) Reinforcement Learning is to neutralize risk, i.e. make the variance of the total reward equal zero.



Answer: 1. 


This is a half-translated note for the coursera course (linked below).  

https://www.coursera.org/learn/reinforcement-learning-in-finance/lecture/PZbAt/introduction-to-markov-decision-processes-and-reinforcement-learning-in-finance