Midterm 2 Review
Q1: Define Sample Space ¶ Sample space is the set all possible of outcomes of an experiment, denoted by Ω \Omega Ω .
For example,
For 2-coin tosses the sample space is
Ω 2-coin = { H H , H T , T H , T T } \Omega_{\text{2-coin}} = \{ HH, HT, TH, TT \} Ω 2-coin = { HH , H T , T H , TT } For roll of a dice with 6-sides
Ω dice = { 1 , 2 , 3 , 4 , 5 , 6 } \Omega_{\text{dice}} = \{1, 2, 3, 4, 5, 6 \} Ω dice = { 1 , 2 , 3 , 4 , 5 , 6 } For weight measurements of an individual, the sample space is the set of all positive real numbers
Ω weight = R + \Omega_{\text{weight}} = \bbR^+ Ω weight = R + Q2: Define Event Space ¶ An event is the set of outcomes that we might be interested in.
Event space is a set of subsets of the sample space.
or example,
For 2-coin tosses the set of all subsets of the sample space in cluding the null set { } \{\} { } and the full sample Ω \Omega Ω
F 2-coin = { { } , { H H } { H T } , { T H } , { T T } , { H H , H T } , … , { H H , H T , T H , T T } ⏟ Ω } \mathcal{F}_{\text{2-coin}} = \{ \{\}, \{ HH \} \{ HT \}, \{ TH \}, \{ TT \}, \{ HH, HT \}, \dots, \underbrace{\{ HH, HT, TH, TT \}}_\Omega \} F 2-coin = {{ } , { HH } { H T } , { T H } , { TT } , { HH , H T } , … , Ω { HH , H T , T H , TT } } For weight measurements of an individual, the event space is be the set of all unions and intersections of intervals (open and closed) of sample space (positive real numbers).
F weight = { ∪ i ∩ j [ a i j , b i j ] : a i j < b i j , a i j ∈ R , b i j ∈ R } \mathcal{F}_{\text{weight}} = \{ \cup_{i} \cap_j [a_{ij}, b_{ij}] : a_{ij} < b_{ij}, a_{ij} \in \bbR , b_{ij} \in \bbR\} F weight = { ∪ i ∩ j [ a ij , b ij ] : a ij < b ij , a ij ∈ R , b ij ∈ R } Q3: Define Power set ¶ The set of all possible subsets of a set Ω \Omega Ω is called a power set and is denoted by 2 Ω 2^{\Omega} 2 Ω .
For roll of a dice with 6-sides
2 Ω = { { } , { H H } { H T } , { T H } , { T T } , { H H , H T } , … , { H H , H T , T H , T T } ⏟ Ω } 2^{\Omega} = \{ \{\}, \{ HH \} \{ HT \}, \{ TH \}, \{ TT \}, \{ HH, HT \}, \dots, \underbrace{\{ HH, HT, TH, TT \}}_\Omega \} 2 Ω = {{ } , { HH } { H T } , { T H } , { TT } , { HH , H T } , … , Ω { HH , H T , T H , TT } } For discrete sample space, event space is the power set of the sample space.
Q4: Define Probability measure ¶ Probability measure is a function P : F → [ 0 , 1 ] P: \mathcal{F} \to [0, 1] P : F → [ 0 , 1 ] that maps from event space to real numbers between [ 0 , 1 ] [0, 1] [ 0 , 1 ] and satisfy the following Kolmogorov axioms
P ( E ) ∈ [ 0 , 1 ] P(E) \in [0, 1] P ( E ) ∈ [ 0 , 1 ] for all E ∈ F E \in \mathcal{F} E ∈ F , where F \mathcal{F} F is event space
P ( Ω ) = 1 P(\Omega) = 1 P ( Ω ) = 1 , where Ω \Omega Ω is sample space
For all disjoint set of events A 1 A_1 A 1 , A 2 A_2 A 2 (A 1 ∩ A 2 = ϕ A_1 \cap A_2 = \phi A 1 ∩ A 2 = ϕ ), the probability of union of events is the sum of individual event probabilities:
P ( A 1 ) + P ( A 2 ) = P ( A 1 ∪ A 2 ) P(A_1) + P(A_2) = P(A_1 \cup A_2) P ( A 1 ) + P ( A 2 ) = P ( A 1 ∪ A 2 ) when A 1 ∩ A 2 = ϕ A_1 \cap A_2 = \phi A 1 ∩ A 2 = ϕ .
In general, for a countably infinite set of event A 1 , A 2 , … A n … ∞ A_1, A_2, \dots A_n \dots \infty A 1 , A 2 , … A n … ∞ ,
P ( ⋃ n = 1 ∞ A n ) = ∑ n = 1 ∞ P ( A n ) P\left(\bigcup_{n=1}^\infty A_n\right) = \sum_{n=1}^\infty P(A_n) P ( n = 1 ⋃ ∞ A n ) = n = 1 ∑ ∞ P ( A n ) when A i ∩ A j = ∞ A_i \cap A_j = \infty A i ∩ A j = ∞ for all i ≠ j i \ne j i = j .
Q5: Define Probability space ¶ The triple of sample space Ω \Omega Ω , event space F \mathcal{F} F and a probability measure P : F → [ 0 , 1 ] P: \mathcal{F} \to [0, 1] P : F → [ 0 , 1 ] is called a probability space.
Q6: Define Random variable ¶ A random variable is a function X : Ω → Q X: \Omega \to \mathbb{Q} X : Ω → Q that maps from sample space Ω \Omega Ω to a space of integers Z \mathbb{Z} Z or real numbers R \mathbb{R} R (in general a measurable space), such that a preimage X − 1 ( B ) ∈ Ω X^{-1}(B) \in \Omega X − 1 ( B ) ∈ Ω of any set of numbers B ∈ Q B \in \mathbb{Q} B ∈ Q exists in the sample space.
For example, a 2-coin toss:
Ω = { H H , H T , T H , T T } \Omega = \{ HH, HT, TH, TT \} Ω = { HH , H T , T H , TT } A random variable maps the elements of sample space to a number,
X ( H H ) = 0 , X ( H T ) = 1 , X ( T H ) = 2 , X ( T T ) = 3 X(HH) = 0, X(HT) = 1, X(TH) = 2, X(TT) = 3 X ( HH ) = 0 , X ( H T ) = 1 , X ( T H ) = 2 , X ( TT ) = 3 By slight abuse of notation, the random variable also maps events to a set of numbers X : F → B X: \mathcal{F} \to B X : F → B ,
X ( { H T , T H , T T } ) = { 1 , 2 , 3 } X(\{HT, TH, TT\}) = \{1, 2, 3\} X ({ H T , T H , TT }) = { 1 , 2 , 3 } Q7: What is the difference between discrete and continuous random variable ¶ Discrete random variable: When the random variable maps the sample space to integers, then the random variable is discrete.
Continuous random variable: When the random variable maps the sample space to real numbers then the random variable is continuous.
Q8: Define Probability mass function (PMF) ¶ For a discrete random variable (RV) the Probability mass function (PMF) is a function that assigns probability value to every discrete value of the random variable, such that
∑ x ∈ Ω P ( X = x ) = 1. \sum_{x \in \Omega} P(X = x) = 1. x ∈ Ω ∑ P ( X = x ) = 1. For example, a die roll
Ω = { 1 , … , 6 } \Omega = \{1, \dots, 6\} Ω = { 1 , … , 6 }
P ( X = 1 ) = 1 / 6 , P ( X = 2 ) = 1 / 6 , … , P ( X = 6 ) = 1 / 6 P(X=1) = 1/6, P(X=2) = 1/6, \dots, P(X=6) = 1/6 P ( X = 1 ) = 1/6 , P ( X = 2 ) = 1/6 , … , P ( X = 6 ) = 1/6 PMF is denoted as multiple symbols P ( X = x ) = P X ( x ) = P ( x ) P(X=x) = P_X(x) = P(x) P ( X = x ) = P X ( x ) = P ( x )
Q9: Define probability density function (PDF) ¶ For a continuous random variable X : Ω → R X: \Omega \to \mathbb{R} X : Ω → R , the probability density function (PDF) is a function f X : R → [ 0 , ∞ ) f_X : \mathbb{R} \to [0, \infty) f X : R → [ 0 , ∞ ) such that:
f X ( x ) ≥ 0 f_X(x) \ge 0 f X ( x ) ≥ 0 for all x ∈ R x \in \mathbb{R} x ∈ R
∫ R f X ( x ) d x = 1 \int_{\mathbb{R}} f_X(x) dx = 1 ∫ R f X ( x ) d x = 1
P ( a ≤ X ≤ b ) = P ( X ∈ [ a , b ] ) = ∫ a b f X ( x ) d x P(a \le X \le b) = P(X \in [a, b]) = \int_a^b f_X(x) dx P ( a ≤ X ≤ b ) = P ( X ∈ [ a , b ]) = ∫ a b f X ( x ) d x
Q10: Define joint probability mass function ¶ P ( X = x , Y = y ) = P ( ( X = x ) ∩ ( Y = y ) ) = P ( ( X = x ) AND ( Y = y ) ) P(X=x, Y=y) = P((X=x) \cap (Y=y)) = P((X=x) \text{ AND } (Y=y)) P ( X = x , Y = y ) = P (( X = x ) ∩ ( Y = y )) = P (( X = x ) AND ( Y = y )) Q11: Define joint probability density function ¶ For two continuous random variable X X X and Y Y Y , the joint probability density function (PDF) is a function f X , Y : ( R , R ) → [ 0 , ∞ ) f_{X,Y} : (\mathbb{R}, \mathbb{R}) \to [0, \infty) f X , Y : ( R , R ) → [ 0 , ∞ ) such that:
f X , Y ( x , y ) ≥ 0 f_{X,Y}(x, y) \ge 0 f X , Y ( x , y ) ≥ 0 for all x , y ∈ R x, y \in \mathbb{R} x , y ∈ R
∫ R ∫ R f X , Y ( x , y ) d x d y = 1 \int_{\mathbb{R}} \int_{\mathbb{R}} f_{X, Y}(x, y) dx dy = 1 ∫ R ∫ R f X , Y ( x , y ) d x d y = 1
P ( a ≤ X ≤ b , c ≤ Y ≤ d ) = P ( X ∈ [ a , b ] , Y ∈ [ c , d ] ) = ∫ c d ∫ a b f X , Y ( x , y ) d x d y P(a \le X \le b, c \le Y \le d) = P(X \in [a, b], Y \in [c, d]) = \int_c^d\int_a^b f_{X,Y}(x, y) dx dy P ( a ≤ X ≤ b , c ≤ Y ≤ d ) = P ( X ∈ [ a , b ] , Y ∈ [ c , d ]) = ∫ c d ∫ a b f X , Y ( x , y ) d x d y
Q12: Define cumulative distribution function ¶ A cumulative distribution function (CDF) is F X ( x ) F_X(x) F X ( x ) is defined as
F X ( x ) = P ( X ≤ x ) . F_X(x) = P(X \le x). F X ( x ) = P ( X ≤ x ) . For a discrete random variable, CDF is the sum of probability mass function
F X ( x ) = P ( X ≤ x ) = ∑ a ≤ x P X ( a ) F_X(x) = P(X \le x) = \sum_{a \le x} P_X(a) F X ( x ) = P ( X ≤ x ) = a ≤ x ∑ P X ( a ) For a continuous random variable, CDF is the integral of probability density function
F X ( x ) = P ( X ≤ x ) = ∫ − ∞ x f X ( z ) d z F_X(x) = P(X \le x) = \int_{-\infty}^{x} f_X(z) dz F X ( x ) = P ( X ≤ x ) = ∫ − ∞ x f X ( z ) d z Q13: Define conditional probability ¶ Conditional probability of event A A A given event B B B is defined as
P ( A ∣ B ) = P ( A , B ) P ( B ) P(A | B) = \frac{P(A, B)}{P(B)} P ( A ∣ B ) = P ( B ) P ( A , B ) when P ( B ) ≠ 0 P(B) \ne 0 P ( B ) = 0 .
Q14: State Bayes theorem ¶ For any two events, A A A and B B B
P ( A ∣ B ) = P ( B ∣ A ) P ( A ) P ( B ) P(A|B) = \frac{P(B|A) P(A)}{P(B)} P ( A ∣ B ) = P ( B ) P ( B ∣ A ) P ( A ) Q15: State Bayes theorem in terms of likelihood, prior, evidence and posterior ¶ For an observable event D D D and a hidden event θ \theta θ , the posterior P ( θ ∣ D ) P(\theta|D) P ( θ ∣ D ) can be estimated using Bayes theorem in terms of likelihood P ( D ∣ θ ) P(D|\theta) P ( D ∣ θ ) , prior P ( θ ) P(\theta) P ( θ ) and evidence P ( D ) P(D) P ( D ) as
P ( θ ∣ D ) = P ( D ∣ θ ) P ( θ ) P ( D ) P(\theta|D) = \frac{P(D|\theta) P(\theta)}{P(D)} P ( θ ∣ D ) = P ( D ) P ( D ∣ θ ) P ( θ ) Q16: Define statistical independence ¶ Two random variables X X X and Y Y Y are said to be independent, denoted as X ⊥ Y X \perp Y X ⊥ Y if any of the following equivalent condition hold for all x , y x, y x , y :
P ( X = x , Y = y ) = P ( X = x ) P ( Y = y ) P(X = x, Y = y) = P(X = x) P(Y = y) P ( X = x , Y = y ) = P ( X = x ) P ( Y = y ) P ( X = x ∣ Y = y ) = P ( X = x ) P(X = x| Y = y) = P(X = x) P ( X = x ∣ Y = y ) = P ( X = x ) P ( Y = y ∣ X = x ) = P ( Y = y ) P(Y = y| X = x) = P(Y = y) P ( Y = y ∣ X = x ) = P ( Y = y ) Q17: Define conditional independence ¶ Two random variables X X X and Y Y Y are said to be conditionally independent given random variable Z Z Z , denoted as X ⊥ Y ∣ Z X \perp Y | Z X ⊥ Y ∣ Z if for all x , y , z x, y, z x , y , z :
P ( X = x , Y = y ∣ Z = z ) = P ( X = x ∣ Z = z ) P ( Y = y ∣ Z = z ) P(X = x, Y = y | Z = z) = P(X = x | Z = z) P(Y = y | Z = z) P ( X = x , Y = y ∣ Z = z ) = P ( X = x ∣ Z = z ) P ( Y = y ∣ Z = z ) Q18: Identically independently distributed (IID) ¶ The random variables (RVs) X 1 , X 2 , … , X n X_1, X_2, \dots, X_n X 1 , X 2 , … , X n are identically independently distributed if they are mutually independent X i ⊥ X j X_i \perp X_j X i ⊥ X j and have the same probability distributions P X i ( x i ) = P X j ( x j ) P_{X_i}(x_i) = P_{X_j}(x_j) P X i ( x i ) = P X j ( x j ) .
Q19: Expectation of a function of a random variable ¶ The expectation of a function g ( X ) g(X) g ( X ) of a discrete random variable X X X is defined as:
E X [ g ( X ) ] = ∑ x ∈ Z P ( X = x ) g ( x ) \mathbb{E}_X[g(X)] = \sum_{x \in \mathbb{Z}} P(X=x) g(x) E X [ g ( X )] = x ∈ Z ∑ P ( X = x ) g ( x ) The expectation of a function g ( X ) g(X) g ( X ) of a continuous random variable X X X is defined as:
E X [ g ( X ) ] = ∫ x ∈ R f X ( x ) g ( x ) d x \mathbb{E}_X[g(X)] = \int_{x \in \mathbb{R}} f_X(x) g(x) dx E X [ g ( X )] = ∫ x ∈ R f X ( x ) g ( x ) d x Q20: What is the difference between sample mean and expectation ¶ Sample mean of n samples is
μ ( X 1 , … , X n ) = 1 n ∑ i = 1 n X i \mu(X_1, \dots, X_n) = \frac{1}{n} \sum_{i=1}^n X_i μ ( X 1 , … , X n ) = n 1 i = 1 ∑ n X i Expectation of a discrete random variable is
E X [ X ] = ∑ x ∈ Ω X P ( X = x ) x \bbE_X[X] = \sum_{x \in \Omega_X} P(X=x) x E X [ X ] = x ∈ Ω X ∑ P ( X = x ) x Sample mean converges to the expectation when n n n with high probability:
lim n → ∞ μ ( X 1 , … , X n ) = E X [ X ] \lim_{n \to \infty} \mu(X_1, \dots, X_n) = E_X[X] n → ∞ lim μ ( X 1 , … , X n ) = E X [ X ] Q21: Define variance of a function of a random variable ¶ The expectation of a function g ( X ) g(X) g ( X ) of a random variable X X X is given by
V X [ g ( X ) ] = E X [ ( g ( X ) − E X [ g ( X ) ] ) 2 ] \bbV_X[g(X)] = \bbE_X\left[ \left(g(X) - \bbE_X[g(X)]\right)^2 \right] V X [ g ( X )] = E X [ ( g ( X ) − E X [ g ( X )] ) 2 ] Q22: Define a covariance matrix ¶ For random vector X = [ X 1 , X 2 , … , X n ] \bfX = [X_1, X_2, \dots, X_n] X = [ X 1 , X 2 , … , X n ] , the covariance matrix of X X X is defined as:
V X [ X ] = E X [ ( X − E X [ X ] ) ( X − E X [ X ] ) ⊤ ] \bbV_X[\bfX] = \bbE_X\left[ \left(\bfX - \bbE_X[\bfX]\right) \left(\bfX - \bbE_X[\bfX]\right)^\top\right] V X [ X ] = E X [ ( X − E X [ X ] ) ( X − E X [ X ] ) ⊤ ] Q23: ¶ Given the dataset D = { ( x 1 , y 1 ) , … , ( x n , y n ) } \calD = \{ (\bfx_1, y_1), \dots, (\bfx_n, y_n) \} D = {( x 1 , y 1 ) , … , ( x n , y n )} , a model y ^ i = f ( x i ; θ ) \hat{y}_i = f(\bfx_i; \theta) y ^ i = f ( x i ; θ ) , and a loss function l ( y i , y ^ i ) l(y_i, \hat{y}_i) l ( y i , y ^ i ) , show that the following optimization problem can be interpreted as maximum likelihood estimation. In the process show that for the interpretation, we need the IID (independently, identically distributed) assumption over the dataset. List any other assumptions that you need for the interpretation.
θ ∗ = arg min θ ∑ i = 1 n l ( y i , f ( x i ; θ ) ) \theta^* = \arg~\min_\theta \sum_{i=1}^n l(y_i, f(\bfx_i; \theta)) θ ∗ = arg θ min i = 1 ∑ n l ( y i , f ( x i ; θ )) A23: ¶ Let the x i \bfx_i x i and y i y_i y i be random vectors for all i i i . Model the probability distribution as a negative log of the loss function:
P ( ( x i , y i ) ∣ θ ) = 1 Z exp ( − l ( y i , f ( x i ; θ ) ) . P((\bfx_i, y_i)| \theta) = \frac{1}{Z} \exp(-l(y_i, f(\bfx_i; \theta)). P (( x i , y i ) ∣ θ ) = Z 1 exp ( − l ( y i , f ( x i ; θ )) . If the samples are IID, then we can write the probability of the entire dataset as products of sample probabilities
P ( D ∣ θ ) = ∏ i = 1 n P ( ( x i , y i ) ∣ θ ) P(\calD|\theta) = \prod_{i=1}^n P((\bfx_i, y_i)| \theta) P ( D ∣ θ ) = i = 1 ∏ n P (( x i , y i ) ∣ θ ) P ( D ∣ θ ) = ∏ i = 1 n 1 Z exp ( − l ( y i , f ( x i ; θ ) ) . P(\calD|\theta) = \prod_{i=1}^n \frac{1}{Z} \exp(-l(y_i, f(\bfx_i; \theta)). P ( D ∣ θ ) = i = 1 ∏ n Z 1 exp ( − l ( y i , f ( x i ; θ )) . A product of exponents is the summation of their powers,
P ( D ∣ θ ) = 1 Z exp ( − ∑ i = 1 n l ( y i , f ( x i ; θ ) ) . P(\calD|\theta) = \frac{1}{Z} \exp(-\sum_{i=1}^n l(y_i, f(\bfx_i; \theta)). P ( D ∣ θ ) = Z 1 exp ( − i = 1 ∑ n l ( y i , f ( x i ; θ )) . Denote
L ( D ; θ ) = ∑ i = 1 n l ( y i , f ( x i ; θ ) . L(\calD; \theta) = \sum_{i=1}^n l(y_i, f(\bfx_i; \theta). L ( D ; θ ) = i = 1 ∑ n l ( y i , f ( x i ; θ ) . The original optimization problem can be written as:
θ ∗ = arg min θ L ( D ; θ ) \theta^* = \arg~\min_\theta L(\calD; \theta) θ ∗ = arg θ min L ( D ; θ ) Taking negative exponent on both sides turns the problem into a maximization problem because exp ( − y ) \exp(-y) exp ( − y ) is a monotonically decreasing function.
θ ∗ = arg max θ exp ( − L ( D ; θ ) ) \theta^* = \arg~\max_\theta \exp(-L(\calD; \theta)) θ ∗ = arg θ max exp ( − L ( D ; θ )) This problem is the same as maximizing the likelihood P ( D ∣ θ ) P(\calD|\theta) P ( D ∣ θ ) , hence maximum likelihood estimate.
Q24: ¶ Given the dataset D = { ( x 1 , y 1 ) , … , ( x n , y n ) } \calD = \{ (\bfx_1, y_1), \dots, (\bfx_n, y_n) \} D = {( x 1 , y 1 ) , … , ( x n , y n )} , a model y ^ i = f ( x i ; θ ) \hat{y}_i = f(\bfx_i; \theta) y ^ i = f ( x i ; θ ) , a regularizer R ( θ ) R(\theta) R ( θ ) and a loss function l ( y i , y ^ i ) l(y_i, \hat{y}_i) l ( y i , y ^ i ) , show that the following optimization problem can be interpreted as maximum-a-posteriori estimation. In the process show that for the interpretation, we need the IID (independently, identically distributed) assumption over the dataset. List any other assumptions that you need for the interpretation.
θ ∗ = arg min θ ∑ i = 1 n l ( y i , f ( x i ; θ ) ) + λ R ( θ ) , \theta^* = \arg~\min_\theta \sum_{i=1}^n l(y_i, f(\bfx_i; \theta)) + \lambda R(\theta), θ ∗ = arg θ min i = 1 ∑ n l ( y i , f ( x i ; θ )) + λ R ( θ ) , where λ \lambda λ is some positive constant that balances between the loss function and the regularizer.
A24: ¶ Let the x i \bfx_i x i and y i y_i y i be random vectors for all i i i . Model the probability distribution as a negative log of the loss function:
P ( ( x i , y i ) ∣ θ ) = 1 Z exp ( − l ( y i , f ( x i ; θ ) ) . P((\bfx_i, y_i)| \theta) = \frac{1}{Z} \exp(-l(y_i, f(\bfx_i; \theta)). P (( x i , y i ) ∣ θ ) = Z 1 exp ( − l ( y i , f ( x i ; θ )) . If the samples are IID, then we can write the probability of the entire dataset as products of sample probabilities
P ( D ∣ θ ) = ∏ i = 1 n P ( ( x i , y i ) ∣ θ ) P(\calD|\theta) = \prod_{i=1}^n P((\bfx_i, y_i)| \theta) P ( D ∣ θ ) = i = 1 ∏ n P (( x i , y i ) ∣ θ ) P ( D ∣ θ ) = ∏ i = 1 n 1 Z exp ( − l ( y i , f ( x i ; θ ) ) . P(\calD|\theta) = \prod_{i=1}^n \frac{1}{Z} \exp(-l(y_i, f(\bfx_i; \theta)). P ( D ∣ θ ) = i = 1 ∏ n Z 1 exp ( − l ( y i , f ( x i ; θ )) . A product of exponents is the summation of their powers,
P ( D ∣ θ ) = 1 Z exp ( − ∑ i = 1 n l ( y i , f ( x i ; θ ) ) . P(\calD|\theta) = \frac{1}{Z} \exp(-\sum_{i=1}^n l(y_i, f(\bfx_i; \theta)). P ( D ∣ θ ) = Z 1 exp ( − i = 1 ∑ n l ( y i , f ( x i ; θ )) . Denote
L ( D ; θ ) = ∑ i = 1 n l ( y i , f ( x i ; θ ) . L(\calD; \theta) = \sum_{i=1}^n l(y_i, f(\bfx_i; \theta). L ( D ; θ ) = i = 1 ∑ n l ( y i , f ( x i ; θ ) . The original optimization problem can be written as:
θ ∗ = arg min θ L ( D ; θ ) + λ R ( θ ) \theta^* = \arg~\min_\theta L(\calD; \theta) + \lambda R(\theta) θ ∗ = arg θ min L ( D ; θ ) + λ R ( θ ) Taking negative exponent on both sides turns the problem into a maximization problem because exp ( − y ) \exp(-y) exp ( − y ) is a monotonically decreasing function.
θ ∗ = arg max θ exp ( − L ( D ; θ ) ) exp ( − λ R ( θ ) ) \theta^* = \arg~\max_\theta \exp(-L(\calD; \theta))\exp(-\lambda R(\theta)) θ ∗ = arg θ max exp ( − L ( D ; θ )) exp ( − λ R ( θ )) The first term is the same as maximizing the likelihood P ( D ∣ θ ) P(\calD|\theta) P ( D ∣ θ ) . If we interpret the second term as a prior:
P ( θ ) = 1 Z ′ exp ( − λ R ( θ ) ) , P(\theta) = \frac{1}{Z'} \exp(-\lambda R(\theta)), P ( θ ) = Z ′ 1 exp ( − λ R ( θ )) , then we can rewrite the original optimization problem as
θ ∗ = arg max θ P ( D ∣ θ ) P ( θ ) \theta^* = \arg~\max_\theta P(\calD|\theta) P(\theta) θ ∗ = arg θ max P ( D ∣ θ ) P ( θ ) By Bayes theorem P ( D ∣ θ ) P ( θ ) = P ( θ ∣ D ) P ( D ) P(\calD|\theta) P(\theta) = P(\theta|\calD)P(\calD) P ( D ∣ θ ) P ( θ ) = P ( θ ∣ D ) P ( D ) , hence we can write the optimization problem as maximizing the posterior
θ ∗ = arg max θ P ( θ ∣ D ) P ( D ) . \theta^* = \arg~\max_\theta P(\theta|\calD) P(\calD). θ ∗ = arg θ max P ( θ ∣ D ) P ( D ) . We can ignore the evidence term P ( D ) P(\calD) P ( D ) , because it is independent of θ \theta θ the optimization variable. The original problem reduces to maximizing the posterior, hence maximum a posteriori:
θ ∗ = arg max θ P ( θ ∣ D ) \theta^* = \arg~\max_\theta P(\theta|\calD) θ ∗ = arg θ max P ( θ ∣ D ) Q25: Define L-p norm for p = { 1 , 2 , … } p = \{1, 2, \dots \} p = { 1 , 2 , … } ¶ ∥ x ∥ p = ( ∣ x 1 ∣ p + ∣ x 2 ∣ p + ⋯ + ∣ x n ∣ p ) 1 p \|\bfx\|_p = \left(|x_1|^p + |x_2|^p + \dots + |x_n|^p \right)^{\frac{1}{p}} ∥ x ∥ p = ( ∣ x 1 ∣ p + ∣ x 2 ∣ p + ⋯ + ∣ x n ∣ p ) p 1 Q26: Find the minimum point for the following regularized least square problem and ¶ w ∗ = arg min w ∥ y − X w ∥ 2 + λ ∥ w ∥ 2 , \bfw^* = \arg~\min_\bfw \|\bfy - \bfX \bfw\|^2 + \lambda \|\bfw\|^2, w ∗ = arg w min ∥ y − Xw ∥ 2 + λ ∥ w ∥ 2 , where w ∈ R n \bfw \in \bbR^n w ∈ R n , y ∈ R m \bfy \in \bbR^m y ∈ R m , X ∈ R m × n \bfX \in \bbR^{m \times n} X ∈ R m × n and λ ∈ R + \lambda \in \bbR^+ λ ∈ R +
A26: ¶ Let f ( w ) = ∥ y − X w ∥ 2 + λ ∥ w ∥ 2 f(\bfw) = \|\bfy - \bfX \bfw\|^2 + \lambda \|\bfw\|^2 f ( w ) = ∥ y − Xw ∥ 2 + λ ∥ w ∥ 2
Write f ( w ) f(\bfw) f ( w ) in terms of inner product,
f ( w ) = ( y − X w ) ⊤ ( y − X w ) + λ w ⊤ w f(\bfw) = (\bfy - \bfX \bfw)^\top(\bfy - \bfX \bfw) + \lambda \bfw^\top \bfw f ( w ) = ( y − Xw ) ⊤ ( y − Xw ) + λ w ⊤ w Expand and collect the terms,
f ( w ) = w ⊤ ( X ⊤ X + λ I n ) w − 2 y ⊤ X w + y ⊤ y f(\bfw) = \bfw^\top (\bfX^\top \bfX + \lambda I_n) \bfw - 2\bfy^\top \bfX \bfw + \bfy^\top \bfy f ( w ) = w ⊤ ( X ⊤ X + λ I n ) w − 2 y ⊤ Xw + y ⊤ y Taking the derivative of f ( w ) f(\bfw) f ( w ) we get,
∂ ∂ w f ( w ) = 2 w ⊤ ( X ⊤ X + λ I n ) − 2 y ⊤ X . \frac{\partial}{\partial \bfw} f(\bfw) = 2 \bfw^\top(\bfX^\top \bfX + \lambda I_n) - 2\bfy^\top \bfX. ∂ w ∂ f ( w ) = 2 w ⊤ ( X ⊤ X + λ I n ) − 2 y ⊤ X . At the maximum point w ∗ \bfw^* w ∗ the derivative of f ( w ) f(\bfw) f ( w ) is zero,
∂ ∂ w f ( w ) ∣ w ∗ = 0 n ⊤ , \left.\frac{\partial}{\partial \bfw} f(\bfw)\right|_{\bfw^*} = \mathbf{0}^\top_n, ∂ w ∂ f ( w ) ∣ ∣ w ∗ = 0 n ⊤ , Equating the derivative to zero at w ∗ \bfw^* w ∗ , we can solve for w ∗ \bfw^* w ∗ ,
2 w ∗ ⊤ ( X ⊤ X + λ I n ) − 2 y ⊤ X = 0 n ⊤ . 2 \bfw^{*\top}(\bfX^\top \bfX + \lambda I_n) - 2\bfy^\top \bfX = \mathbf{0}^\top_n. 2 w ∗ ⊤ ( X ⊤ X + λ I n ) − 2 y ⊤ X = 0 n ⊤ . Rearranging we get,
w ∗ = ( X ⊤ X + λ I n ) − 1 X ⊤ y \bfw^* = (\bfX^\top \bfX + \lambda I_n)^{-1} \bfX^\top \bfy w ∗ = ( X ⊤ X + λ I n ) − 1 X ⊤ y