



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Homework Assignment # Solutions
p(x; μ, σ^2 , H 0 ) = (2πσ^2 )−N^ exp
2 σ^2
j=
i=
(xij − μ)^2
p(x; μ 1 , μ 2 , σ^2 , H 1 ) = (2πσ^2 )−N^ exp
2 σ^2
j=
i=
(xij − μj )^2
so that the GLRT test with an ML threshold is
(2πˆσ 12 )−N^ exp
− (^) 2ˆ^1 σ 2 1
j=
i=1(xij^ −^ μˆj^ )
2
(2πσˆ^20 )−N^ exp
− (^) 2ˆ^1 σ 2 0
j=
i=1(xij^ −^ μˆ) 2
d 1
< d 0
Using the definition of the estimated parameters, the exponential terms in both the numerator and the denominator become exp(−N ), yielding ( σˆ^20 σ ˆ^21
)N d 1
< d 0
or more simply σˆ^20 σ ˆ^21
d 1
< d 0
as the test. (b) Note that
∑^ N
i=
(xij − μˆ)^2 =
i=
(xij − μˆj + ˆμj − μˆ)^2
i=
(xij − μˆj )^2 + 2(ˆμj − μˆ)
i=
(xij − μˆj ) +
i=
(ˆμj − μˆ)^2
i=
(xij − μˆj )^2 + N (ˆμj − μˆ)^2.
Therefore
2 N σˆ^20 = 2N σˆ^21 + N
j=
(ˆμj − μˆ)^2
and 2 N σˆ^20 2 N σˆ^21
d 1
< d 0
j=1(ˆμj^ −^ μˆ) 2
2 N ˆσ 12
d 1
< d 0
The right hand side is SSgr SSres
d 1
< d 0
p(x; α, σ^2 , H 1 ) = (2πσ^2 )−N/^2 exp
2 σ^2
n (^0) ∑+N − 1
n=n 0
(x(n) − αs(n − n 0 ))^2
p(x; σ^2 , H 0 ) = (2πσ^2 )−N/^2 exp
2 σ^2
n (^0) ∑+N − 1
n=n 0
x^2 (n)
As we have seen previously,
ˆσ^20 =
n (^0) ∑+N − 1
n=n 0
x^2 (n).
(a) We have
ln
p(x; α, σ^2 , H 1 )
ln(2πσ^2 ) −
2 σ^2
n (^0) ∑+N − 1
n=n 0
(x(n) − αs(n − n 0 ))^2
∂ ln(p) ∂α
2 σ^2
n 0 +∑N − 1
n=n 0
2 (x(n) − αs(n − n 0 )) (−s(n − n 0 ))
σ^2
n (^0) ∑+N − 1
n=n 0
s(n − n 0 ) (x(n) − αs(n − n 0 )).
Setting this equal to zero and solving for α yields
αˆ =
∑n 0 +N − 1 n=n 0 x(n)s(n^ −^ n^0 ) ∑n 0 +N − 1 n=n 0 s (^2) (n − n 0 )
(b) We have
p(x; H 1 ) = (2πσˆ^21 )−N/^2 exp
2ˆσ 12
n (^0) ∑+N − 1
n=n 0
(x(n) − αsˆ (n − n 0 ))^2
= (2πσˆ^21 )−N/^2 exp
N ˆσ 12 2ˆσ^21
= (2πσˆ^21 )−N/^2 exp
Part (ii) results in the following plot.
0 5 10 15 20 25
1
n 0 / 10^4
LG
(x) at n
0
Signal D
There are three peaks, corresponding to the presence of three occurrences of the call in this signal. We determine from the plot that they occur at 2.3, 3.9, and 8.1 seconds. Matlab code that produces the plots appears below and on the following pages.
% Load in the signals. load hw4signals
% implement the GLRT using the ML threshold to each of the four signals
call = call’ ; % the code below uses call as a column vector N = length(call);
% apply first to signal_A signal = signal_A ; M = length(signal); LR = zeros(1,(M-N)+1); for k=1:(M-N)+1, x = (signal(k:k+N-1))’ ; sig_0 = (x’x)/N ; alpha = (x’call)/(call’*call) ;
sig_1 = (x-alphacall)’(x-alpha*call)/N ; LR(k) = sig_0/sig_1 ; end LR_A = LR ;
% apply to signal_B LR = zeros(1,(M-N)+1); signal = signal_B ; for k=1:(M-N)+1, x = (signal(k:k+N-1))’ ; sig_0 = (x’x)/N ; alpha = (x’call)/(call’call) ; sig_1 = (x-alphacall)’(x-alphacall)/N ; LR(k) = sig_0/sig_1 ; end LR_B = LR ;
% apply to signal_C LR = zeros(1,(M-N)+1); signal = signal_C ; for k=1:(M-N)+1, x = (signal(k:k+N-1))’ ; sig_0 = (x’x)/N ; alpha = (x’call)/(call’call) ; sig_1 = (x-alphacall)’(x-alphacall)/N ; LR(k) = sig_0/sig_1 ; end LR_C = LR ;
% plot the results figure(1) time = [0:length(LR)-1]/10000 ; % time in sample number, normalized subplot(131) plot(time,log(LR_A.^(N/2))) axis([0 6 ylim]) title(’Signal A’) xlabel(’n_0 / 10^4’) ylabel(’ln(L_G(x)) at n_0’) subplot(132) plot(time,log(LR_B.^(N/2))) axis([0 6 ylim]) title(’Signal B’) xlabel(’n_0 / 10^4’) subplot(133) plot(time,log(LR_C.^(N/2)))