Chapter 4: squared-error loss/risk
Chapter 4: squared-error loss/risk
In the lefthand column (a) of plots, we define three posterior distributions for landing positions of the arrow, when the location of the aimpoint is nominally zero (upper plot). We then ask, via a decision-theoretic analysis making use of the quadratic loss function, ‘by how much should we shift these (nominally unshifted) probability distributions to minimize risk?’. We see (lower plot) that the triangular posterior need not be shifted (its minimum risk-point is at zero). To minimize risk with the other two distributions, one must be shifted positively and one negatively (by about 0.5 and -1 units, respectively) so that the mean of the distribution is at the bullseye.
%quadratic loss / risk
%aimpoint calculations
%
figure(5); clf
thetas=linspace(-3,3,1200);
Tlist=[1 2]; grylist=[.0 .5 .75]; collist=[.2 .3 .6; .4 .5 .9]; LW=1.4; xminmax=[-2.5 2.5];
for iT=1:length(Tlist), subplot(2,1,1), hold on
plist=[zeros(1,sum(thetas<-1.15)) linspace(0,1,sum(and(thetas<=0,thetas>=-1.15))) linspace(1,0,sum(and(thetas<=1.15,thetas>0))) zeros(1,sum(thetas>1.15))];
plot(thetas,plist,'.','Color',grylist(1)*[1 1 1])
%loss function
plot(thetas,Tlist(iT)*(thetas).^2,'-','Color',collist(iT,:),'LineWidth',LW);
subplot(2,1,2); hold on
ptot=sum(plist);
r=nan(size(plist));
for inow=1:length(thetas), dtheta=thetas(inow);
loss=Tlist(iT)*abs(dtheta+thetas).^2;
r(inow)=sum(plist.*loss); end
plot(thetas,r/ptot,'.','Color',grylist(1)*[1 1 1]); rmin=mean(r(isnear(r,min(r))))/ptot;
plot(mean(thetas(isnear(r,min(r)))),rmin,'ko','MarkerFaceColor',collist(iT,:),'MarkerSize',8);
subplot(2,1,1); hold on
plist=npdf(thetas,0,1);
plist=plist+npdf(thetas,-1,.25); plist=plist/max(plist);
plot(thetas,plist,'.','Color',grylist(2)*[1 1 1]);
subplot(2,1,2); hold on
ptot=sum(plist);
r=nan(size(plist));
for inow=1:length(thetas), dtheta=thetas(inow);
loss=Tlist(iT)*abs(dtheta+thetas).^2;
r(inow)=sum(plist.*loss); end
plot(thetas,r/ptot,'.','Color',grylist(2)*[1 1 1]);
plot(thetas(isnear(r,min(r))),r(isnear(r,min(r)))/ptot,'ko','MarkerFaceColor',collist(iT,:),'MarkerSize',8);
subplot(2,1,1), hold on
thetas=linspace(-3,3,1200);
plist=[zeros(1,700) linspace(0,1,200)]; plist=[plist(1:end-1) linspace(1,0,201) zeros(1,100)];
plist=plist+npdf(thetas,.5,.5); plist=plist/max(plist);
plot(thetas,plist,'.','Color',grylist(3)*[1 1 1]);
subplot(2,1,2); hold on
ptot=sum(plist);
for inow=1:length(thetas), dtheta=thetas(inow);
loss=Tlist(iT)*abs(dtheta+thetas).^2;
r(inow)=sum(plist.*loss); end
plot(thetas,r/ptot,'.','Color',grylist(3)*[1 1 1]);
plot(thetas(isnear(r,min(r))),r(isnear(r,min(r)))/ptot,'ko','MarkerFaceColor',collist(iT,:),'MarkerSize',8); end
subplot(2,1,1); axis([-2.5 2.5 0 1])
subplot(2,1,2); axis([-2.5 2.5 0 1.5])
In the righthand column of plots (b) we plot three risk functions, each one associated with a different target-width but with the same posterior probability over arrow endpoints, and all using the quadratic loss function. Here, the minimum risk point tells us which location along the theta axis to choose as our measurement of the (as-yet unseen) arrow endpoint. This point is always the mean of the distribution, and the extent to which the mean is preferred over other choices (predictions) is given by the width of the loss function.
%quadratic loss / risk
%estimate = mean
%
Tlist=[.5 1 2]; grylist=[.4 .6 .8]; collist=[.2 .3 .6; .3 .4 .8; .4 .5 .9]; LW=1.4; xminmax=[-3 3];
thetas=linspace(-3,3,1200);
plist=npdf(thetas,1,1);
plist=plist+npdf(thetas,-0,.25); plist=plist/max(plist);
figure(6); clf;
%plot distribution of
subplot(2,1,1); hold on
plot(thetas,plist/max(plist),'k.')
%plot squares for target radii
for iT=1:length(Tlist),
plot(thetas,Tlist(iT)*(thetas+2).^2,'.','Color',grylist(iT)*[1 1 1]); end
axis([xminmax 0 1])
%plot risk function for each target
subplot(2,1,2); hold on
ptot=sum(plist);
tlist=find(abs(thetas)<=2);
for iT=1:length(Tlist), T=Tlist(iT); r=nan(size(tlist));
for inow=1:length(tlist), dtheta=thetas(tlist(inow));
loss=T*abs(thetas-dtheta).^2;
r(inow)=sum(plist.*loss)/ptot; end
plot(thetas(tlist),r,'.','Color',grylist(iT)*[1 1 1]);
imax=find(isnear(r,min(r)));
plot(mean(thetas(tlist(imax))),mean(r(imax)),'ko','MarkerFaceColor',collist(iT,:),'MarkerSize',8); end
axis([xminmax 0 2]); axis off