function [dbx,dby] = bound_spec(dbp,x,y,dbtype,nbr); % function [dbx,dby] = bound_spec(dbp,x,y,dbtype,nbr); % dbDN, D = x,y is the domain on which the decision bound function is % defined, so if D = x, it serves primarily to divide the 'upper' % region from the 'lower' region, whereas if D = y, it serves to divide % the 'left' from the 'right'. lenx = length(x); leny = length(y); if strcmp(dbtype,'linear') dbx(1,:) = dbp(1,1)*( x + dbp(1,5) ).^3 + dbp(1,2)*( x + dbp(1,5) ).^2 + dbp(1,3)*( x + dbp(1,5) ) + dbp(1,4); dby(1,:) = dbp(2,1)*( y + dbp(2,5) ).^3 + dbp(2,2)*( y + dbp(2,5) ).^2 + dbp(2,3)*( y + dbp(2,5) ) + dbp(2,4); if nbr == 5 dbx(2,:) = dbp(1,1)*( x + dbp(1,5) ).^3 + dbp(1,2)*( x + dbp(1,5) ).^2 + dbp(3,3)*( x + dbp(1,5) ) + dbp(3,4); dbx(3,:) = dbp(1,1)*( x + dbp(1,5) ).^3 + dbp(1,2)*( x + dbp(1,5) ).^2 + dbp(5,3)*( x + dbp(1,5) ) + dbp(5,4); dby(2,:) = dbp(2,1)*( y + dbp(2,5) ).^3 + dbp(2,2)*( y + dbp(2,5) ).^2 + dbp(6,3)*( y + dbp(2,5) ) + dbp(6,4); dby(3,:) = dbp(2,1)*( y + dbp(2,5) ).^3 + dbp(2,2)*( y + dbp(2,5) ).^2 + dbp(4,3)*( y + dbp(2,5) ) + dbp(4,4); end elseif strcmp(dbtype,'piecewise') if nbr == 1 dbx = ones(1,lenx); dby = ones(1,leny); miny3p = length( x( x < min( dbp(2,3:4) ) ) ); maxy3p = lenx - length( x( x > max( dbp(2,3:4) ) ) ); minx3p = length( y( y < min( dbp(1,3:4) ) ) ); maxx3p = leny - length( y( y > max( dbp(1,3:4) ) ) ); elseif nbr == 5 dbx = ones(3,lenx); dby = ones(3,leny); miny3p = length( x( x < min( dbp(6,3:4) ) ) ); maxy3p = lenx - length( x( x > max( dbp(6,3:4) ) ) ); minx3p = length( y( y < min( dbp(3,3:4) ) ) ); maxx3p = leny - length( y( y > max( dbp(3,3:4) ) ) ); end % dbx1 cx = dbp(1,3); dx = dbp(1,4); dbx(1,1:miny3p) = dbx(1,1:miny3p) * cx; dbx(1,maxy3p:lenx) = dbx(1,maxy3p:lenx) * dx; % changes made 4/10/08 to take care of 'divide by zero' problem slope_num = dx-cx; slope_den = (x(maxy3p)-x(miny3p)); if slope_den == 0 slope = 0; else slope = slope_num/slope_den; end itcpt = dx - slope * x(maxy3p); dbx(1,miny3p+1:maxy3p-1) = slope * x(miny3p+1:maxy3p-1) + itcpt; % dby2 cy = dbp(2,3); dy = dbp(2,4); dby(1,1:minx3p) = dby(1,1:minx3p) * cy; dby(1,maxx3p:leny) = dby(1,maxx3p:leny) * dy; % slope = (dy-cy)/(y(maxx3p)-y(minx3p)); % changes made 4/10/08 to take care of 'divide by zero' problem slope_num = dy-cy; slope_den = (y(maxx3p)-y(minx3p)); if slope_den == 0 slope = 0; else slope = slope_num/slope_den; end itcpt = dy - slope * y(maxx3p); dby(1,minx3p+1:maxx3p-1) = slope * y(minx3p+1:maxx3p-1) + itcpt; if nbr == 5 % dbx3 cx = dbp(3,3); dx = dbp(3,4); dbx(2,1:miny3p) = dbx(2,1:miny3p) * cx; dbx(2,maxy3p:lenx) = dbx(2,maxy3p:lenx) * dx; % slope = (dx-cx)/(x(maxy3p)-x(miny3p)); % changes made 4/10/08 to take care of 'divide by zero' problem slope_num = dx-cx; slope_den = (x(maxy3p)-x(miny3p)); if slope_den == 0 slope = 0; else slope = slope_num/slope_den; end itcpt = dx - slope * x(maxy3p); dbx(2,miny3p+1:maxy3p-1) = slope * x(miny3p+1:maxy3p-1) + itcpt; % dbx5 cx = dbp(5,3); dx = dbp(5,4); dbx(3,1:miny3p) = dbx(3,1:miny3p) * cx; dbx(3,maxy3p:lenx) = dbx(3,maxy3p:lenx) * dx; % slope = (dx-cx)/(x(maxy3p)-x(miny3p)); % changes made 4/10/08 to take care of 'divide by zero' problem slope_num = dx-cx; slope_den = (x(maxy3p)-x(miny3p)); if slope_den == 0 slope = 0; else slope = slope_num/slope_den; end itcpt = dx - slope * x(maxy3p); dbx(3,miny3p+1:maxy3p-1) = slope * x(miny3p+1:maxy3p-1) + itcpt; % dby3 cy = dbp(6,3); dy = dbp(6,4); dby(2,1:minx3p) = dby(2,1:minx3p) * cy; dby(2,maxx3p:leny) = dby(2,maxx3p:leny) * dy; % slope = (dy-cy)/(y(maxx3p)-y(minx3p)); % changes made 4/10/08 to take care of 'divide by zero' problem slope_num = dy-cy; slope_den = (y(maxx3p)-y(minx3p)); if slope_den == 0 slope = 0; else slope = slope_num/slope_den; end itcpt = dy - slope * y(maxx3p); dby(2,minx3p+1:maxx3p-1) = slope * y(minx3p+1:maxx3p-1) + itcpt; % dby4 cy = dbp(4,3); dy = dbp(4,4); dby(3,1:minx3p) = dby(3,1:minx3p) * cy; dby(3,maxx3p:leny) = dby(3,maxx3p:leny) * dy; % slope = (dy-cy)/(y(maxx3p)-y(minx3p)); % changes made 4/10/08 to take care of 'divide by zero' problem slope_num = dy-cy; slope_den = (y(maxx3p)-y(minx3p)); if slope_den == 0 slope = 0; else slope = slope_num/slope_den; end itcpt = dy - slope * y(maxx3p); dby(3,minx3p+1:maxx3p-1) = slope * y(minx3p+1:maxx3p-1) + itcpt; end elseif strcmp(dbtype,'maxpost') % these bounds are a function of the distributions, so there. % % given the need to plot these bastards, it would probably be a % good idea to go ahead and figure out how to derive the bounds % in terms of weighted piecewise quadratic functions based on % pairs of densities else error('dbtype is misspecified: it must be "linear", "piecewise", or "maxpost"') end