Commit 8d7c3e34 authored by Ling Sun's avatar Ling Sun
Browse files

save all optimal paths

parent acf89c06
......@@ -23,7 +23,7 @@ outdir = '/home/ling.sun/O1/Viterbi/output/';
outfile = strcat(outdir,'Viterbi-', num2str(startFreq),'.dat')
% Set parameters
a0median = 1.44
a0median = 1.805
P = 68023.70496
steps = 13
......@@ -33,36 +33,42 @@ tic
toc
fmean = f(1)+0.5; % Take the mean value of each 1-Hz sub-band
g = [-0.1:0.01:0.1]; % asini grid (+/-10% uncertainty, may search larger uncertainty)
g = [-0.8:0.05:0.8]; % asini grid (+/-80% uncertainty)
a0 = (1+g)*a0median; % asini values being searched
for m=1:length(g)
disp(sprintf('a0=%g',a0(m)))
tic
% Generate Bessel-weighted matched filter
[b,h] = binaryfilter(f,fmean,P,a0(m));
[b,h] = binaryfilter(f,fmean,P,a0(m));
% Compute Bessel-weighted Fstat
% Compute Bessel-weighted Fstat
for n=1:steps
Y(:,n) = fftshift(ifft(fft(X(:,n)).*fft(b)));
end
% Viterbi tracking
[path0(m,:), delta, psi, sc(m)] = viterbi_colFLT(3, Y);
[path0(m,:), delta, psi, sc(m)] = viterbi_colFLT(3, Y);
toc
end
% Get the optimal path for all asini searched
[maxsc, a0ind] = max(sc)
path = path0(a0ind,:)
%[maxsc, a0ind] = max(sc)
%path = path0(a0ind,:)
% Save output file for each 1-Hz sub-band
fid = fopen(outfile,'wt');
fprintf(fid,'StartFreq\t%g\n',startFreq);
fprintf(fid,'Score\t%g\n',maxsc);
fprintf(fid,'Bin_a0\t%g\n',a0ind);
fprintf(fid,'Path');
fprintf(fid,'\n%d',path);
fprintf(fid,'%%StartFreq\t%g\n',f(1));
fprintf(fid,'%%Score\ta0\tPath\n');
for m=1:length(g)
fprintf(fid,'%g\t%g\t',sc(m),a0(m));
for n=1:steps
fprintf(fid,'%d\t',path0(m,n));
end
fprintf(fid,'\n');
end
fclose(fid);
clear all
......@@ -41,15 +41,13 @@ cor = (0:Q-1)'-(M-1)/2;
t = 1;
delta(:,t) = obslik(:,t);
% Recursion and Termination
disp('forward')
% Forward - Recursion and Termination
for t=2:T
delta(:,t) = colfilt(delta(:,t-1),[M 1],'sliding',@max) + obslik(:,t);
psi(:,t) = colfilt(delta(:,t-1),[M 1],'sliding',@argmax) + cor;
end
% Optimal path backtracking
disp('backward')
[sc, path(T)] = max(delta(:,T));
score = (sc-mean(delta(:,T)))/std(delta(:,T));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment