Chapter 5: measuring the qrs duration
Chapter 5: measuring the qrs duration
%plot the data histogram
figure(1); load('qrsdat.mat');
[n,x]=hist(tdat,20);
bar(x,n,1,'FaceColor',.45*[1 1 1]); box off; hold on
%compute the 2D (log) probability
Fpdf=@(MT,S) log(S)-log(ones(size(tdat))*(MT-50))+(S-1)*log((tdat-50)*(1./(MT-50)))-2*log(1+((tdat-50)*(1./(MT-50))).^S);
mt=linspace(50,200,302); mt=mt(2:end); SP=linspace(1,10,201); Lfisk=nan(201,301);
for nSP=1:201,
Lfisk(nSP,:)=sum(Fpdf(mt,SP(nSP)),1); end
figure(3); mesh(mt,SP,exp(Lfisk-max(max(Lfisk)))); colormap bone
%Compute and plot marginal posteriors
Lmt=logsum(Lfisk,1); Lsp=logsum(Lfisk,2); Lmt=Lmt-max(Lmt); Lsp=Lsp-max(Lsp);
MThat=logpeakval([Lmt mt(:)]);
SPhat=logpeakval([Lsp SP(:)]);
figure(2); subplot(2,1,1); hold on
plot(mt,Lmt,'k.'); plot(MThat*[1 1],[min(Lmt) 0],'k--'); axis([50,200,min(Lmt),0]); box off
subplot(2,1,2); hold on
plot(SP,Lsp,'k.'); plot(SPhat*[1 1],[min(Lsp) 0],'k--'); axis([1,10,min(Lsp),0]); box off
%Compute sampling distribution for best-fit parameters
t=linspace(50,150,302); t=t(2:end);
LfiskT=log(SPhat)-log(MThat-50)+(SPhat-1)*log((t-50)./(MThat-50))-2*log(1+((t-50)./(MThat-50)).^SPhat);
figure(1); plot(t,122*exp(LfiskT-max(LfiskT)),'--','Color',.65*[1 1 1],'LineWidth',2.5)