view m-toolbox/classes/+utils/@math/stnr.m @ 50:7d2e2e065cf1 database-connection-manager

Update unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:37 +0100
parents f0afece42f48
children
line wrap: on
line source

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Compute Signal-to-Noise Ratio for temperature annealing in mcmc as  
% described in Neil J. Cornish et al (arXiv:gr-qc/0701167v1).
% Returns SNR for each channel.
%
% - Inputs are -the outputs from both channels
%              -the inverse cross-spectrum matrix elements
%              -the template (arXiv:gr-qc/0701167v1)
% 
% Karnesis 24-07-2011
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function snrexp = stnr(tmplt1,tmplt2,out1,out2,InvS11,InvS22,InvS12,InvS21)

 if tmplt2 == 0 
   hs = 4*real(sum(abs(tmplt1.*(InvS11.*conj(out1)))));
   hh = 4*real(sum(abs(tmplt1.*(InvS11.*conj(tmplt1)))));
   snrexp = sqrt(2)*hs/sqrt(hh);     
 else
   hs1 = 4*real(sum(abs(tmplt1.*(InvS11.*conj(out1) + InvS12.*conj(out2)))));
   hs2 = 4*real(sum(abs(tmplt2.*(InvS21.*conj(out1) + InvS22.*conj(out2)))));
 
   hh1 = 4*real(sum(abs(tmplt1.*(InvS11.*conj(tmplt1) + InvS12.*conj(tmplt2)))));
   hh2 = 4*real(sum(abs(tmplt2.*(InvS21.*conj(tmplt1) + InvS22.*conj(tmplt2)))));

   %snrexp = [sqrt(2)*hs1/sqrt(hh1) sqrt(2)*hs2/sqrt(hh2)];
   snrexp = sqrt(2)*(hs1+hs2)/sqrt(hh1+hh2);
 
 end
 
end