📄 examp.m
字号:
%% Reinitialize everything.%clearrand('seed',0);randn('seed',0);%% Get the problem.%load shawexamp.mat%% Set the data covariance matrix.%CD=1.0e-12*eye(20);%% Setup the prior.%mprior=0.5*ones(20,1);CM=0.25*eye(20); %% Compute the posterior distribution.%[covmp,mmap]=bayes(G,mprior,CM,dn,CD);%% Compute a second solution with a more diffuse prior.%mprior2=mprior;CM2=100*CM;[covmp2,mmap2]=bayes(G,mprior2,CM2,dn,CD);%% Now, produce some plots.%figure(1);clf;bookfonts;plotconst(spike,-pi/2,pi/2);axis([-2 2 -0.5 1.5]);hold onplotconstc(mmap,-pi/2,pi/2,'k--');xlabel('\theta');ylabel('Intensity');legend('Target Model','MAP Solution');%print -deps mmap.eps%% Now, with error bars.%figure(2);bookfonts;plotconst(mmap,-pi/2,pi/2);axis([-2 2 -1.0 1.5]);hold onplotconstc(mmap+1.96*sqrt(diag(covmp)),-pi/2,pi/2,'k--');plotconstc(mmap-1.96*sqrt(diag(covmp)),-pi/2,pi/2,'k--');xlabel('\theta');ylabel('Intensity');legend('MAP Solution','95% Prob Interval');%print -deps mmapb.eps%% Generate a random solution.%figure(3);bookfonts;mmapsims=simmvn(mmap,covmp);plotconst(mmapsims,-pi/2,pi/2);bookfonts;xlabel('\theta');ylabel('Intensity');%print -deps mmapsims.eps%% Now, with error bars for the more diffuse prior.%figure(4);clf;bookfonts;plotconst(mmap2,-pi/2,pi/2);hold onplotconstc(mmap2+1.96*sqrt(diag(covmp2)),-pi/2,pi/2,'k--');plotconstc(mmap2-1.96*sqrt(diag(covmp2)),-pi/2,pi/2,'k--');xlabel('\theta');ylabel('Intensity');legend('MAP Solution','95% Prob Interval');%print -deps mmap2.eps
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -