-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEM_Smth.m
More file actions
32 lines (28 loc) · 758 Bytes
/
EM_Smth.m
File metadata and controls
32 lines (28 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [valh,alphah]=EM_Smth(val0,Noise_Var,Jp)
% smoothing observed parameters val0 using EM algorithm
% Yu Hang, Mar. 2012, NTU
p=size(Jp,1);
alpha0=0;
Rinv=spdiags(1./Noise_Var.',0,p,p);
y = sparse(val0./Noise_Var).';
for nt = 1:2000
Kpost = alpha0*Jp+Rinv;
x = Kpost\y;
% L = LowRankApp(4,W1,S1,W2,S2,nscale,cscale1,cscale2);
alphah = (p-1)/(trace(Jp/Kpost)+x'*Jp*x); %
if abs((alphah-alpha0)/alpha0)<1e-4 || rcond(full(alpha0*Jp+Rinv))<5e-16 %/alpha0
break;
else
alpha0=alphah;
end
if rem(nt,100) == 0;
nt;
end
end
if rcond(full(alpha0*Jp+Rinv))<5e-16 || nt == 2000
valh= sum(y)/sum(diag(Rinv))*ones(1,p);
alphah=Inf;
else
x=(alphah*Jp+Rinv)\Rinv*val0';
valh=x';
end