RL 001
Reinforcement Learning
- Learn how to make a good sequence of decisions by interacting with the environment.

Characteristics of RL
- Trial and Error: Based learning approach.
- Optimization: Find good sequences of actions or decisions.
- Delayed Consequences/Rewards: Takes time to relize the actions or decisions are good or bad.
- Exploration: Learn by making decisions or forming actions or through experiences. Trying new actions to discover their effects.
- Exploitation: Choosing actions with the highest expected reward, based on current knowledge.
- Generalization: Use previous experiences or knowledge to new or unseen situations effectively.
Framwork of RL
- OpenAI Gym
- Torch RL
- AWS DeepRacer
RL Math
Probability
- Sample Space (): The set of all possible outcomes of a random experiment.
Bonferroni's Inequality
- Gives a lower bound on the intersection probability which is useful when this probability is difficult to compute directly.
- It is useful when the probabilities of individual events are sufficiently large.
Boole's Inequality
for any sets .
- It is useful when finding an upper bound for the probabilities of the union of events.
Bayes' Rule
- It allows us to compute the conditional probability from the inverse conditional probability .
- Let be a partition of the sample space . Then let be any subset of we have:
Independent Events
-
A family of events is independent if for every finite subset we have:
-
The pair-wise independence of events does not imply their mutual independence.
Conditional Independence
- where .
- or equivalently, and .
Induced Probability Function
- is the sample space.
- is a random variable with range .
- The result set is the set of all outcomes in the sample space that map to the value under the random variable .
Cumulative Distribution Function (CDF)
- is a cdf the following conditions hold:
- Monotonicity: is non-decreasing.
- Limiting values: and .
- Right-Continuity: .
F_X(t)
1.0 | ●────────────
| ↑ ↑ ↑
| 3.001 3.01 3.1
0.7 | ●─────────○
| ↑ ↑ ↑
| 2.001 2.01 2.1
0.3 | ●────────○
| ↑ ↑ ↑
| 1.001 1.01 1.1
0.0 |─────○
+-------------------------------------- t
1 2 3
x x x
Continuous & Discrete Random Variables
- if is continuous, then is continuous and differentiable almost everywhere. The probability density function (pdf) is defined as:
- if is discrete, then is a step function and the probability mass function (pmf) is defined as:
1 ────────────────────────━━━━━━━━
╱
╱
╱
╱
0 ━━━━━━━━━━━━━━━───────────────── x
1 ─────────────────────────●━━━━━━
│
0.7 ─────────────●━━━━━━━━━○
│
0.3 ─────●━━━━━━━○
│
0 ━━━━━━━○──────────────────────── x
1 2 3
1 ──────────────────────────━━━━━━
╱
╱
0.7 ───────────●━━━━━━━
│
0.5 ───────────○
╱
╱
0 ━━━━━━━━──────────────────────── x
a
Probability Mass Function (PMF)
- A discrete random variable is given by for .
- It represents the probability that the first success occurs exactly on the -th trial in a sequence of independent trials.
Probability Density Function (PDF)
- A continuous random variable is given by for .
- The probability is calculated as the area under the probability density function over a specific interval.
Expectation
- Linearity: for any constants , , and .
- Non-negativity: If then because it is a weighted average of non-negative values.
- Monotonicity: If then because it is a weighted average of values that are greater than or equal to the corresponding values of .
- Boundedness: If then because it is a weighted average of values that are bounded by and .
a ●──────────────●──────────────● b
가능한 값들 평균
E[X]
Moments
-
The central moment of is:
-
1th central moment is the mean, .
-
2th central moment is the variance, .
- It emphasizes the variability of the distribution.
- for any constants and .
-
3th central moment is the skewness, .
- It emphasizes the skewness of the distribution.
-
4th central moment is the kurtosis, .
- It emphasizes the tail behavior and extreme values of the distribution.
Covariance
- It measures how muc htwo random variables change together.
- Negative Covariance
- Near Zero Covariance
- Positive Covariance
Y: 시험 점수
높음 | ●
| ● ●
| ●
| ●
낮음 | ●
+-------------------- X: 공부 시간
적음 많음
Cov(X,Y) > 0
Correlation
- Individual variances must be non-zero.
- lies in the range .
Joint Distributions
- Joint Probability Mass Function (PMF) for discrete random variables and .
Y
1 ┤ ● 1/4 ● 1/4
│ (0,1) (1,1)
0 ┤ ● 1/4 ● 1/4
│ (0,0) (1,0)
└──────────────────── X
0 1
Marginal Distributions
- Fixing one variable and summing over the other variable gives the marginal distribution of the fixed variable.
Y=0 Y=1 행의 합
X=0 0.10 0.20 0.30
X=1 0.30 0.40 0.70
─────────────────────────
열의 합 0.40 0.60 1.00
- : sum of the first row.
- : sum of the second row.
- : sum of the first column.
- : sum of the second column.
- Marginalization: It sums or integrates over all possible values of an unwanted variable to obtain the distribution of the variable of interest.

Conditional Distributions
- It represents the probability distribution of given that has a specific value.
- If , then is undefined.

Bernoulli Distribution
- The outcome of a Bernoulli trial is either a success (1) or a failure (0).
Binomial Distribution
- probability of success in a single trial:
- probability of failure in a single trial:
- The binomial distribution describes the number of successes in a fixed number of independent Bernoulli trials.
-
Geometric Distribution
- probability of success in a single trial:
- probability of failure in a single trial:
- The geometric distribution describes the number of trials before the first success in a sequence of independent Bernoulli trials.
-
Uniform Distribution
- The uniform distribution describes a continuous random variable that has an equal probability of taking any value within a specified range.
- The probability depends on the length of the interval, not its location.
Normal Distribution
- Central Limit Theorem: the distribution of the sum (or average) of a large number of independent, identically distributed variables will be approximately normal, regardless of the underlying distribution.
Multivariate Normal Distribution
- is the -dimensional mean vector.
- is the covariance matrix.
- is the determinant of the covariance matrix.
Beta Distribution
- is the gamma function.
α < β α = β α > β
높이 높이 높이
│╲ │ ╭──╮ │ ╱
│ ╲___ │ ╭─╯ ╰─╮ │ ___╱
└──────── x └────────── x └──────── x
0 1 0 1 0 1
0 쪽 강조 가운데 강조 1 쪽 강조
Beta(8,2) Beta(80,20)
╭────╮ /\
╭─╯ ╰─╮ / \
─────╯ ╰─── ─────/────\─────
0.8 0.8
불확실성 큼 불확실성 작음
-
- where new observations are successes and failures.
- The Beta distribution is a distribution of success probabilities for a Bernoulli or Binomial distribution.
- Application
- Measuring uncertainty in the probability of success for a Bernoulli or Binomial distribution.
- Conversion rate or click-through rate (CTR) in online advertising.
- Defect rate in manufacturing.







