\underline{Problem Set 2}

MAS 622J/1.126J: Pattern Recognition and Analysis

Due: 5:00 p.m. on September 30

[Note: All instructions to plot data or write a program should be carried out using Matlab. In order to maintain a reasonable level of consistency and simplicity we ask that you do not use other software tools.]

If you collaborated with other members of the class, please write their names at the end of the assignment. Moreover, you will need to write and sign the following statement: “In preparing my solutions, I did not look at any old homeworks, copy anybody’s answers or let them copy mine.”

Problem 1: [10 Points]

In many pattern classification problems we have the option to either assign a pattern to one of c classes, or reject it as unrecognizable - if the cost to reject is not too high. Let the cost of classification be defined as:

λ(ω_{i}|ω_{j}) = \begin{cases}0 & if ω _{i} = ω _{j}, (i.e. Correct Classification) \\ λ_{r} & if ω _{i} = ω _{0}, (i.e. Rejection) \\ λ_{s} & Otherwise, (i.e. Substitution Error) \end{cases}

Show that for the minimum risk classification, the decision rule should associate a test vector x with class ω _{i}, if P(ω _{i}|x ) ≥ P(ω _{j}|x ) for all j and and P(ω _{i} | x ) ≥ 1 - \frac{λ_{r}}{λ_{s}}, and reject otherwise. Solution: Average risk is choosing class ω_{i}:

R(ω_{i}|x) = ∑_{j=1}^{c} λ(ω_{i}|ω_{j})P (ω_{j}|x) = 0^{∗}P (ω_{i}|x) + ∑_{j=1,j!=i}^{c} λ_{s}P (ω_{j}|x)

where λ(ω_{i}|ω_{j}) is used to mean the cost of choosing class ω_{i} where the true class is ωj.

Hence:

R(ω_{i}|x) = λ_{s}(1 − P (ω_{i}|x))

Associate x with the class ω_{i} if highest posterior class probability and the average risk is less than the cost of rejection:

λ_{s}(1 − P (ω_{i}|x)) ≤ λ_{r}
P (ω_{i}|x) ≥ 1 − λ_{r}/λ_{s}

Problem 2: [16 points]

In a particular binary hypothesis testing application, the conditional density for a scalar feature x given class w_{1} is

p(x|w_{1}) = k_{1} exp(−x^{2}/20)

Given class w_{2} the conditional density is

p(x|w_{2}) = k_{2} exp(−(x − 6)^{2}/12)

a. Find k_{1} and k_{2}, and plot the two densities on a single graph using Matlab.

Solution: We solve for the parameters k_{1} and k_{2} by recognizing that the two equations are in the form of the normal Gaussian distribution.

k_{1}e^{\frac{−x^{2}}{20}} = \frac{1}{\sqrt{2πσ_{1}^{2}}} e^{\frac{−(x−μ_{1})^{2}}{2σ^{2}_{1}}}
\frac{−x^{2}}{20} = \frac{−(x − μ_{1})^{2}}{2σ_{1}^{2}}
μ_{1} = 0; σ_{1}^{2} = 10
k_{1} = \frac{1}{\sqrt{20π}}

Figure 1: The pdf and decision boundaries

In a similar fashion, we find that

μ_{2} = 6; σ_{2}^{2} = 6
k_{2} = \frac{1}{\sqrt{12π}}

These distributions are plotted in Figure 1.

b. Assume that the prior probabilities of the two classes are equal, and that the cost for choosing correctly is zero. If the costs for choosing incorrectly are C_{12} = \sqrt{3} and C_{21} = \sqrt{5} (where C_{ij} corresponds to predicting class i when it belongs to class j), what is the expression for the conditional risk?

Solution: The conditional risk for Two-Category Classification is discussed in Section 2.2.1 in D.H.S. where we can see that the formulas for the risk associated with the action, α_{i}, of classifying a feature vector, x, as class, ω_{i}, is different for each action:

R(α_{1}|x) = λ_{11}P (ω_{1}|x) + λ_{12}P (ω_{2}|x)
R(α_{2}|x) = λ_{21}P (ω_{1}|x) + λ_{22}P (ω_{2}|x)

The prior probabilities of the two classes are equal:

P (ω_{1}) = P (ω_{2}) = \frac{1}{2}

The assumption that the cost for choosing correctly is zero:

λ_{11} = 0, λ_{22} = 0

The costs for choosing incorrectly are given as C_{12} and C_{21}:

λ_{12} = C_{12} = \sqrt{3}
λ_{21} = C_{21} = \sqrt{5}

Thus the expression for the conditional risk of α_{1} is:

R(α_{1}|x) = λ_{11}P (ω_{1}|x) + λ_{12}P (ω_{2}|x)
R(α_{1}|x) = 0P (ω_{1}|x) + \sqrt{3}P (ω_{2}|x)
R(α_{1}|x) = \sqrt{3}P (ω_{2}|x)

And the expression for the conditional risk of α_{2}:

R(α_{2}|x) = λ_{21}P (ω_{1}|x) + λ_{22}P (ω_{2}|x)
R(α_{2}|x) = \sqrt{5}P (ω_{1}|x) + 0P (ω_{2}|x)
R(α_{2}|x) = \sqrt{5}P (ω_{1}|x)

c. Find the decision regions which minimize the Bayes risk, and indicate them on the plot you made in part (a)

Solution: The Bayes Risk is the integral of the conditional risk when we use the optimal decision regions, R_{1} and R_{2}. So, solving for the optimal decision boundary is a matter of solving for the roots of the equation:

R(α_{1}|x) = R(α_{2}|x)
\sqrt{3}P (ω_{2}|x) = \sqrt{5}P (ω_{1}|x)
\frac{\sqrt{3}P (x|ω_{2})P (ω_{2})}{P (x)} = \frac{\sqrt{5}P (x|ω_{1})P (ω_{1})}{P (x)}

Given the priors are equal this simplifies to:

\sqrt{3}P (x|ω_{2}) = \sqrt{5}P (x|ω_{1})

Next, using the values, k_{1} and k_{2}, from part (a), we have expressions for p_{x|ω_{1}} and p_{x|ω_{2}}.

\sqrt{3}\frac{1}{\sqrt{12π}} e^{\frac{−(x−6)^{2}}{12}} = \sqrt{5}\frac{1}{\sqrt{20π}} e^{\frac{−x^{2}}{20}}
e^{\frac{−(x−6)^{2}}{12}} = e^{\frac{−x^{2}}{20}}
\frac{−(x − 6)^{2}}{12} = \frac{−x^{2}}{20}
20(x^{2} − 12x + 36) = 12x^{2}
8x^{2} − 240x + 720 = 0

The decision boundary is found by solving for the roots of this quadratic, x_{1} = 15 − 3\sqrt{15} = 3.81 and x_{2} = 15 + 3\sqrt{15} = 26.62

d. For the decision regions in part (c), what is the numerical value of the Bayes risk?

Solution: For x < 15 − 3\sqrt{15} the decision rule will choose ω_{1} For 15 − 3\sqrt{15} < x < 15 + 3\sqrt{15} the decision rule will choose ω_{2} For 15 + 3\sqrt{15} < x the decision rule will choose ω_{1}

Thus the decision region R_{1} is x < 15 − 3\sqrt{15} and x > 15 + 3\sqrt{15}, and the decision region R_{2} is 15 − 3\sqrt{15} < x < 15 + 3\sqrt{15}.

Risk = ∫_{R_{1}} λ_{11}P (ω_{1}|x) + λ_{12}P (ω_{2}|x)

+ ∫_{R_{2}} λ_{21}P (ω_{1}|y) + λ_{22}P (ω_{2}|y)

= ∫_{R_{1}} λ_{12}P (y|ω_{2})P (ω_{2}) + ∫_{R_{2}} λ_{21}P (y|ω_{1})P (ω_{1})

= ∫_{y=− inf}^{y=15−3\sqrt{15}} \sqrt{3}N(6, 6)\frac{1}{2} + ∫_{y=15+3\sqrt{15}}^{y=inf} \sqrt{3}N(6, 6)\frac{1}{2}

+ ∫_{y=15−3\sqrt{15}}^{y=15+3\sqrt{15}} \sqrt{5}N(0, 10)\frac{1}{2}

= \frac{\sqrt{3}}{2} ((\frac{1}{2} + \frac{1}{2}erf(((15 − 3\sqrt{15}) − 6)/\sqrt{12})) + (\frac{1}{2} − \frac{1}{2}erf(((15 + 3\sqrt{15}) − 6)/\sqrt{12})))

+ \frac{\sqrt{5}}{2} (\frac{1}{2}erf((15 + 3\sqrt{15})/\sqrt{20}) − \frac{1}{2}erf((15 − 3\sqrt{15})/\sqrt{20}))

= 0.6824

Problem 3: [16 points]

Let’s consider a simple communication system. The transmitter sends out messages m = 0 or m = 1, occurring with a priori probabilities \frac{3}{4} and \frac{1}{4} respectively. The message is contaminated by a noise n, which is independent from m and takes on the values -1, 0, 1 with probabilities \frac{1}{8}, \frac{5}{8}, and \frac{2}{8} respectively. The received signal, or the observation, can be represented as r = m + n. From r, we wish to infer what the transmitted message m was (estimated state), denoted using m̂. m̂ also takes values on 0 or 1. When m = m̂, the detector correctly receives the original message, otherwise an error occurs.

a. Find the decision rule that achieves the maximum probability of correct decision. Compute the probability of error for this decision rule.

Solution: It is equivalent to find the decision rule that achieves the minimum probability of error. The receiver decides the transmitted message is 1, i.e., m̂ = 1 if

Figure 2: A simple receiver

P (r|m = 1) · P r(m = 1) ≥ P (r|m = 0) · P r(m = 0)
P (r|m = 1) ≥ P (r|m = 0) · 3  (1)

Otherwise the receiver decides m̂ = 0. The likelihood functions for these two cases are

P (r|m = 1) = \begin{cases}\frac{1}{8} & if r = 0 \\ \frac{5}{8} & if r = 1 \\ \frac{2}{8} & if r = 2 \\ 0 & otherwise \end{cases}

P (r|m = 0) = \begin{cases}\frac{1}{8} & if r = −1 \\ \frac{5}{8} & if r = 0 \\ \frac{2}{8} & if r = 1 \\ 0 & otherwise \end{cases}

Eq. 1 holds only when r = 2. Therefore, the decision rule can be summarized as

m̂ = \begin{cases}1 & if r = 2 \\ 0 & otherwise \end{cases}

The probability of error is as follows:

P r(e) = P r(m̂ = 1|m = 0) · P r(m = 0) + P r(m̂ = 0|m = 1) · P r(m = 1)
= P r(r = 2|m = 0) · P r(m = 0) + P r(r ≠ 2|m = 1) · P r(m = 1)
= 0 + (\frac{1}{8} + \frac{5}{8}) · \frac{1}{4} = \frac{3}{16} = 0.1875

b. Let’s have the noise n be a continuous random variable, uniformly distributed between \frac{−3}{4} and \frac{2}{4}, and still statistically independent of m. First, plot the pdf of n. Then, find a decision rule that achieves the minimum probability of error, and compute the probability of error.

Solution:

The uniform distribution is plotted in Figure 3.

The decision rule is still determined by using Eq. 1. The likelihood functions become continuous, instead of discrete in (a):

Figure 3: The pdf of n

P (r|m = 1) = \begin{cases}\frac{4}{5} & if \frac{1}{4} < r ≤ \frac{6}{4} \\ 0 & otherwise \end{cases}

P (r|m = 0) = \begin{cases}\frac{4}{5} & if \frac{−3}{4} < r ≤ \frac{2}{4} \\ 0 & otherwise \end{cases}

The interesting region is where the two pdf’s overlap with each other, namely when \frac{1}{4} < r ≤ \frac{2}{4}. From Eq. 1, we know we should decide m̂ = 0 for this range. The decision rule can be summarized as

m̂ = \begin{cases}0 & if \frac{−3}{4} < r ≤ \frac{1}{4} \\ 0 & if \frac{1}{4} < r ≤ \frac{2}{4} \\ 1 & if \frac{2}{4} < r ≤ \frac{6}{4} \end{cases}

Note that at the decision boundaries, there is ambiguity on which decision we should make. Again, either decision won’t change the probability of error, so it is acceptable to decide both ways.

The probability of error is

P r(e) = P r(m̂ = 1|m = 0) · P r(m = 0) + P r(m̂ = 0|m = 1) · P r(m = 1)
= P r(\frac{1}{4} < r ≤ \frac{2}{4}|m = 1) · P r(m = 1)
= (\frac{2}{4} − \frac{1}{4}) · \frac{4}{5} · \frac{1}{4} = \frac{1}{20}

Problem 4: [16 points]

[Note: Use Matlab for the computations, but make sure to explicitly construct every transformation required, that is either type it or write it. Do not use Matlab if you are asked to explain/show something.]

Consider the three-dimensional normal distribution p(x|w) with mean μ and covariance matrix Σ where

μ = ( \begin{matrix}3 \\ 1 \\ 2 \end{matrix} ) , Σ = ( \begin{matrix}1 & 0 & 0 \\ 0 & 5 & 4 \\ 0 & 4 & 5 \end{matrix} ) .

Compute the matrices representing the eigenvectors and eigenvalues Φ and Λ to answer the following questions: Solution:

Λ = ( \begin{matrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 9 \end{matrix} ) , Φ = ( \begin{matrix}1 & 0 & 0 \\ 0 & −\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ 0 & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \end{matrix} ) .

a. Find the probability density at the point x_{0} = (5 6 3)^{T}

Solution:

p(x_{0}|ω) = \frac{1}{(2π)^{3/2}|Σ|^{1/2}} e^{\frac{−(x_{0}−μ)^{T} Σ^{−1}(x_{0}−μ)}{2}}  (2)

|Σ| = 9; Σ^{−1} = ( \begin{matrix}1 & 0 & 0 \\ 0 & \frac{5}{9} & \frac{−4}{9} \\ 0 & \frac{−4}{9} & \frac{5}{9} \end{matrix} )

The squared Mahalanobis distance from the mean to x_{0} is:

(x_{0} − μ)^{T} Σ^{−1}(x_{0} − μ) =

[( \begin{matrix}5 \\ 6 \\ 3 \end{matrix} ) − ( \begin{matrix}3 \\ 1 \\ 2 \end{matrix} )]^{T} ( \begin{matrix}1 & 0 & 0 \\ 0 & \frac{5}{9} & \frac{−4}{9} \\ 0 & \frac{−4}{9} & \frac{5}{9} \end{matrix} ) [( \begin{matrix}5 \\ 6 \\ 3 \end{matrix} ) − ( \begin{matrix}3 \\ 1 \\ 2 \end{matrix} )]

= 14

We plug these values in to find that the density at x_{0} is:

p(x_{0}|ω) = 1.2866e − 5

b. Construct an orthonormal transformation y = Φ^{T} x. Show that for orthonormal transformations, Euclidean distances are preserved (i.e., ∥y∥^{2} = ∥x∥^{2}).

Solution:

y = Φ^{T} x

= ( \begin{matrix}1 & 0 & 0 \\ 0 & −\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ 0 & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \end{matrix} )^{T} x

To prove that for orthonormal transformations, Euclidean distances are preserved we have to show that ||y||^{2} = ||x||^{2}.

Proof : Let y be a random variable such that y = A^{T} x where A^{T} is an orthonormal transformation (i.e., A^{T} A = I)

||y||^{2} = y^{T} y

= (A^{T} x)^{T} A^{T} x = x^{T} AA^{T} x = x^{T} x = ||x||^{2} c. After applying the orthonormal transformation add another transfor-

mation Λ^{−1/2} and convert the distribution to one centered on the origin with covariance matrix equal to the identity matrix. Remember that A_{w} = ΦΛ^{−1/2} is a linear transformation (i.e., A_{w}(ax + by) = aA_{w}x + bA_{w}y) Solution:

u = Λ^{−1/2}y

= ( \begin{matrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & \frac{1}{\sqrt{9}} \end{matrix} ) y

Where u can also be expressed as u = Λ^{−1/2}Φ^{T} x Let u = A_{w}^{T} x where A_{w} = ΦΛ^{−1/2}. Given p(x|w) ∼ N(μ, Σ) then p(u|w) ∼ N(A_{w}^{T} μ, A_{w}^{T} ΣA_{w}) Since u is a result of a whitening transform to x, then the covariance matrix of u is proportional to the Identity matrix I. In this case, since Φ is a matrix of normalized eigenvectors of Σ and Λ is the eigenvalue matrix, the transformation A^{T} = Λ^{−1/2}Φ^{T} makes the covariance matrix equal to I. Therefore, to convert the distribution to one centered on the origin with the covariance equal to the Identity matrix, it is enough to define a new variable z such that z = A_{w}^{T} x−A_{w}^{T} μ. In that way p(z|w) ∼ N(0, 1).

d. Apply the same overall transformation to x_{0} to yield a transformed point x_{w} Solution:

x_{w} = A_{w}^{T} x_{0} − A_{w}^{T} μ

= A_{w}^{T} (x_{0} − μ)

= ( \begin{matrix}1 & 0 & 0 \\ 0 & −\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ 0 & \frac{1}{\sqrt{18}} & \frac{1}{\sqrt{18}} \end{matrix} ) ( \begin{matrix}2 \\ 5 \\ 1 \end{matrix} )

= ( 2 ; \frac{−4}{\sqrt{2}} ; \frac{6}{\sqrt{18}} )

e. Calculate the Mahalanobis distance from x_{0} to the mean μ and from x_{w} to 0. Are they different or are they the same? Why?

Solution: The squared Mahalanobis distance from x_{0} to the mean μ, we found in part (a), is .9514

The squared Mahalanobis distance from x_{w} to 0 is:

x_{w}^{T} x_{w} = ( 2 ; \frac{−4}{\sqrt{2}} ; \frac{6}{\sqrt{18}} )^{T} ( 2 ; \frac{−4}{\sqrt{2}} ; \frac{6}{\sqrt{18}} ) = 14

The two distances are the same, as expected under any linear transformation.

Problem 5: [16 Points]

Use signal detection theory as well as the notation and basic Gaussian assumptions described in the text to address the following.

a. Prove that P (x > x^{∗}|x ∈ w_{2}) and P (x > x^{∗}|x ∈ w_{1}), taken together, uniquely determine the discriminability d′

Solution: Let x = x and x^{∗} = x^{∗}. Based on the Gaussian assumption, we see that P (x > x^{∗}|x ∈ w_{i}) = P (\frac{x−μ_{i}}{σ_{i}} > \frac{x^{∗}−μ_{i}}{σ_{i}} |x ∈ w_{i}) ∼ N(0, 1)

for i = 1, 2 Thus, we know (\frac{x−μ_{2}}{σ_{2}} ) from the hit rate P (x > x^{∗}|x ∈ w_{2})

and (\frac{x−μ_{1}}{σ_{1}} ) from the false alarm rate P (x > x^{∗}|x ∈ w_{1}), and these let us calculate the discriminability.

|\frac{x^{∗} − μ_{1}}{σ_{1}} − \frac{x^{∗} − μ_{2}}{σ_{2}} | = |\frac{x^{∗} − μ_{1}}{σ} − \frac{x^{∗} − μ_{2}}{σ} |

= |\frac{μ_{2} − μ_{1}}{σ} |

= \frac{|μ_{2} − μ_{1}|}{σ}

= d′

Therefore d′ is uniquely determined by the hit and false alarm rates.

b. Use error functions erf(∗) to express d′ in terms of the hit and false alarm rates. Estimate d′ if P (x > x^{∗}|x ∈ w_{1}) = .7 and P (x > x^{∗}|x ∈ w_{2}) = .5. Repeat for d′ if P (x > x^{∗}|x ∈ w_{1}) = .9 and P (x > x^{∗}|x ∈ w_{2}) = .15.

Solution: There are a couple of ways in which you can proceed. This document will detail one of them.

Let y be a random variable such that P (y > y^{∗}|y ∈ w_{i}) ∼ N(0, 1) for i = 1, 2.

\frac{1}{\sqrt{2π}} ∫_{0}^{y^{∗}} e^{− \frac{t^{2}}{2}} dt = \frac{1}{\sqrt{π}} ∫_{0}^{y^{∗}} \frac{1}{\sqrt{2}}e^{− \frac{t^{2}}{2}} dt

let u = \frac{t}{\sqrt{2}}; du = \frac{dt}{\sqrt{2}}

= \frac{1}{\sqrt{π}} ∫0^{\frac{y^{∗}}{\sqrt{2}}} e^{−u^{2}}du

= \frac{1}{2}erf (\frac{y^{∗}}{\sqrt{2}})

Then, given that P (x > x^{∗}|x ∈ w_{i}) = P (\frac{x−μ_{i}}{σ_{i}} > \frac{x^{∗}−μ_{i}}{σ_{i}} |x ∈ w_{i}) ∼ N(0, 1) for i = 1, 2.

P (\frac{x − μ_{i}}{σ_{i}} > \frac{x^{∗} − μ_{i}}{σ_{i}} |x ∈ w_{i}) = 1 − P (\frac{x − μ_{i}}{σ_{i}} < \frac{x^{∗} − μ_{i}}{σ_{i}} |x ∈ w_{i})

= \begin{cases}1 − (\frac{1}{2} + \frac{1}{2}erf (\frac{x^{∗}−μ_{i}}{\sqrt{2}σ_{i}} )) & if \frac{x^{∗}−μ_{i}}{σ_{i}} > 0 \\ 1 − (\frac{1}{2} − \frac{1}{2}erf (\frac{μ_{i}−x^{∗}}{\sqrt{2}σ_{i}} )) & if \frac{x^{∗}−μ_{i}}{σ_{i}} < 0 \end{cases}

= \begin{cases}\frac{1}{2} − \frac{1}{2}erf (\frac{x^{∗}−μ_{i}}{\sqrt{2}σ_{i}} ) & if \frac{x^{∗}−μ_{i}}{σ_{i}} > 0 \\ \frac{1}{2} + \frac{1}{2}erf (\frac{μ_{i}−x^{∗}}{\sqrt{2}σ_{i}} ) & if \frac{x^{∗}−μ_{i}}{σ_{i}} < 0 \end{cases}

= \begin{cases}\frac{1}{2} (1 − erf (\frac{x^{∗}−μ_{i}}{\sqrt{2}σ_{i}} )) & if \frac{x^{∗}−μ_{i}}{σ_{i}} > 0 \\ \frac{1}{2} (1 + erf (\frac{μ_{i}−x^{∗}}{\sqrt{2}σ_{i}} )) & if \frac{x^{∗}−μ_{i}}{σ_{i}} < 0 \end{cases}

Therefore:

\frac{x^{∗} − μ_{i}}{σ_{i}} = \sqrt{2} (erf^{−1}[1 − 2P (x > x^{∗}|x ∈ w_{i})]) if P (x > x^{∗}|x ∈ w_{i}) < .5
\frac{μ_{i} − x^{∗}}{σ_{i}} = \sqrt{2} (erf^{−1}[2P (x > x^{∗}|x ∈ w_{i}) − 1]) if P (x > x^{∗}|x ∈ w_{i}) > .5

Then to find the values of erf^{−}1() use a table of erf, a table of the cumulative normal distribution, or use Matlab erf and erfinv functions.

d_{1}^{∗} = |−\frac{μ_{1} − x^{∗}}{σ} − \frac{x^{∗} − μ_{2}}{σ} |
= |−\sqrt{2} (erf^{−1}[2(.7) − 1]) − \sqrt{2} (erf^{−1}[2(.5) − 1])|
= |−\sqrt{2} (erf^{−1}[.4]) − \sqrt{2} (erf^{−1}[0])|
= .5244

d_{2}^{∗} = |−\frac{μ_{1} − x^{∗}}{σ} − \frac{x^{∗} − μ_{2}}{σ} |
= |−\sqrt{2} (erf^{−1}[2(.9) − 1]) − \sqrt{2} (erf^{−1}[1 − 2(.15)])|
= |−\sqrt{2} (erf^{−1}[.8]) − \sqrt{2} (erf^{−1}[.7])|
= 2.3180

c. Given that the Gaussian assumption is valid, calculate the Bayes error for both the cases in (b).

Solution: Given

Pr[error] = P (w_{1})ϵ_{1} + P (w_{2})ϵ_{2}
where ϵ_{1} = ∫_{χ_{2}} p(x|w_{1})dx and ϵ_{2} = ∫_{χ_{1}} p(x|w_{2})dx

Since the regions χ_{1} and χ_{2} are defined by our decision boundary x^{∗}. We can see that

ϵ_{1} = ∫_{χ_{2}} p(x|w_{1})dx = P (x < x^{∗}|x ∈ w_{1}) = 1 − P (x > x^{∗}|x ∈ w_{1})
Similarly
ϵ_{2} = ∫_{χ_{1}} p(x|w_{2})dx = P (x > x^{∗}|x ∈ w_{2})

Therefore,

Pr[error1] = (1 − .7)P (w_{1}) + (.5)P (w_{2})
Pr[error2] = (1 − .9)P (w_{1}) + (.15)P (w_{2})

And if the priors are equally likely,

Pr[error1] = .4
Pr[error2] = .125

d. Using a trivial one-line computation or a graph determine which case has the higher d′, and explain your logic:

Case A: P (x > x^{∗}|x ∈ w_{1}) = .75 and P (x > x^{∗}|x ∈ w_{2}) = .35.
Case B: P (x > x^{∗}|x ∈ w_{1}) = .8 and P (x > x^{∗}|x ∈ w_{2}) = .25.

Solution: From part (b) we can calculate the discriminability given the hit and false alarm rates, and see that Case B has a higher discriminability.

d_{1}^{∗} = |−\frac{μ_{1} − x^{∗}}{σ} − \frac{x^{∗} − μ_{2}}{σ} |
= |−\sqrt{2} (erf^{−1}[2(.75) − 1]) − \sqrt{2} (erf^{−1}[1 − 2(.35)])|
= |−\sqrt{2} (erf^{−1}[.5]) − \sqrt{2} (erf^{−1}[.3])|
= 1.0598

d_{2}^{∗} = |\frac{x^{∗} − μ_{1}}{σ} + \frac{μ_{2} − x^{∗}}{σ} |
= |\sqrt{2} (erf^{−1}[1 − 2(.25)]) + \sqrt{2} (erf^{−1}[2(.8) − 1])|
= |\sqrt{2} (erf^{−1}[.5]) + \sqrt{2} (erf^{−1}[.6])|
= 1.5161

Key point of this problem: The error function erf is related to the cumulative normal distribution. Assuming that the probability of x belonging to one of two classes is Gaussian, then knowing the values of the false alarm and hit rates for an arbitrary x^{∗} is enough to compute the discriminability d′. Moreover, if the Gaussian assumption holds, a determination of the discriminability allows us to calculate the Bayes error rate.

Problem 6: [16 Points]

a. Show that the maximum likelihood (ML) estimation of the mean for a Gaussian is unbiased but the ML estimate of variance is biased (i.e., slightly wrong). Show how to correct this variance estimate so that it is unbiased.

Solution: Sample mean is unbiased:

E[μ̂] = E[\frac{1}{n} ∑_{i=1}^{n} x_{i}]

= \frac{1}{n} ∑_{i=1}^{n} E[x_{i}]

= \frac{1}{n} ∑_{i=1}^{n} μ

= \frac{1}{n}nμ

= μ

This document will show two ways to prove that the sample variance is biased. Proof 1:

E[∑_{i=1}^{n}(x_{i} − μ̂)^{2}] = E[∑_{i=1}^{n}(x_{i})^{2}] − nE[μ̂^{2}]

= nE[(x_{i})^{2}] − \frac{1}{n}E[(∑_{i=1}^{n} x_{i})^{2}]

= n(var(x_{i}) + (E[x_{i}])^{2}) − \frac{1}{n}E[(∑_{i=1}^{n} x_{i})^{2}]

= nσ^{2} + \frac{1}{n}(nE[x_{i}])^{2}) − \frac{1}{n}E[(∑_{i=1}^{n} x_{i})^{2}]

= nσ^{2} − \frac{1}{n}[E[(∑_{i=1}^{n} x_{i})^{2}] − (E[∑_{i=1}^{n} x_{i}])^{2}]

= nσ^{2} − \frac{1}{n}var(∑_{i=1}^{n} x_{i})

= nσ^{2} − \frac{1}{n}nσ^{2}

= (n − 1)σ^{2} Proof 2:

E[σ̂_{ML}^{2}] = E[\frac{1}{n} ∑_{i=1}^{n}(x_{i} − μ̂)^{2}]

= \frac{1}{n} ∑_{i=1}^{n} E[x_{i}^{2} − 2x_{i}μ̂ + μ̂^{2}]

= \frac{1}{n} ∑_{i=1}^{n} E[x_{i}^{2}] − 2μ̂E[∑_{i=1}^{n} x_{i}] + ∑_{i=1}^{n} E[μ̂^{2}]

= \frac{1}{n}[n(σ^{2} + μ^{2}) − 2nE[μ̂^{2}] + nE[μ̂^{2}]]

= \frac{1}{n}[nσ^{2} + nμ^{2} − nE[μ̂^{2}]]

= \frac{1}{n}[nσ^{2} + nμ^{2} − n(fracσ^{2}n + μ^{2})]

= \frac{n − 1}{n}σ^{2}

T herefore

unbiased: σ̂^{2} = \frac{n}{n − 1}σ̂_{ML}^{2}

= \frac{1}{n − 1} ∑_{i=1}^{n}(x_{i} − μ̂)^{2}

b. For this part you’ll write a program with Matlab to explore the biased and unbiased ML estimations of variance for a Gaussian distribution. Find the data for this problem on the class webpage as ps2.mat. This file contains n=5000 samples from a 1-dimensional Gaussian distribution.

Solution:

(a) Write a program to calculate the ML estimate of the mean, and report the output.

(b) Write a program to calculate both the biased and unbiased ML estimate of the variance of this distribution. For n=1 to 5000, plot the biased and unbiased estimates of the variance of this Gaussian.

This is as if you are being given these samples sequentially, and each time you get a new sample you are asked to re-evaluate your estimate of the variance. Give some interpretation of your plot. The dataset was generated from a Gaussian normal distribution ∼ N(9, 2). The following Matlab code calculates the ML estimate of the mean = 9, and produces Figure 6 indicating that the variance = 2.0.

load ps2.mat;
data=ps2;
n = length(data)
%ML estimate of mean:
MLmean = sum(data) / n
MLvar = [];
unMLvar = [];
%ML estimate of variance:
for(i=2:n)
    varML = 0;
    tempMean = sum(data(1:i)) / i;
    for (j=1:i)
        varML = varML + (data(j) - tempMean)^2;
    end
    MLvar(i) = varML/i;
    x = data(1:i);
    unMLvar(i) = cov(data(1:i));
end
figure
plot(1:1:n, MLvar(1:n), 'g', 1:1:n, unMLvar(1:n), 'r')

Problem 7: [10 Points]

Suppose x and y are random variables. Their joint density, depicted below, is constant in the shaded area and 0 elsewhere,

a. Let ω_{1} be the case when x ≤ 0, and ω_{2} be the case when x > 0. Determine the a priori probabilities of the two classes P(ω_{1}) and P(ω_{2}).

Figure 4: Though the two estimators have quite different estimates in the first few samples, the bias looses significance as n is large, and both estimators give the true variance of the data σ = 1.0.

Figure 5: The joint distribution of x and y.

Let y be the observation from which we infer whether ω_{1} or ω_{2} happens. Find the likelihood functions, namely, the two conditional distributions p(y|ω_{1}) and p(y|ω_{2}).

Solution:

By simply counting the number of unit squares in the shaded areas on the left and right sides of the line x = 0; we can directly find out that there are 8 unit squares on each side. Thus, the two cases are equally likely, i.e. P(ω_{1}) = P(ω_{2}) = 0.5.

It’s also pretty straightforward to obtain the likelihood functions p(y|ω_{1}) and p(y|ω_{2}) by counting the number of unit squares for different ranges of y. We just need to be careful with normalizing them such that the integral of the distribution 1. See Figure 6.

b. Find the decision rule that minimizes the probability of error, and calculate what the probability of error is. Please note that there will be ambiguities at decision boundaries, but how you classify when y falls on the decision boundary doesn’t affect the probability of error.

Solution: As shown in (a), the a priori probabilites of ω_{1} and ω_{2} are identical. The minimum probability of error decision rule simply relies on the comparison of the two likelihood function, In other words, it becomes a ML decision rule.

The decision rule can be summarized as:

ω̂ = \begin{cases}ω_{1} if -2 < y ≤ -1 or 1 < y ≤ 2 \\ ω_{2} if -1 < y ≤ 1 \end{cases}

The probability of error is thus:

P r(e) = P r(ω̂ = ω_{1}|ω_{2})P r(ω_{1}) + P r(ω_{1}|ω_{2})P r(ω_{2})
= \frac{1}{2}P r(−1 < y ≤ 1|ω_{1}) + \frac{1}{2}P r(−2 < y ≤ −1, 1 < y ≤ 2|ω_{2})
= \frac{1}{2} ∗ \frac{1}{2} + \frac{1}{2} ∗ \frac{1}{4} = \frac{3}{8}

Figure 6: Likelihood functions: (a) p(y| ω_{1}) top, (b) p(y| ω_{2}) bottom 25