% % Problem Epage 200 % Example 5.18 Epage 162 % % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- clear all; close all; clc; %-- % plot the multidimensional Gaussian %-- % create a grid for the domain: [x,y,z] = meshgrid(-3:.1:3,-3:.1:3,-3:.1:3); [n,d] = size(x(:)); % fill our volume with values of the trivariate normal density: a = (2*pi)^(3/2); arg = (x.^2+y.^2+z.^2); prob = exp((-0.5)*arg)/a; % draw a slice at an ARBITRARY angle: hs = surf(linspace(-3,3,20),linspace(-3,3,20),zeros(20)); % rotate the surface about the direction vector [1,-1,1] and 30 degrees: rotate(hs,[1,-1,1],30); % get the data that will define the surface at an arbitrary angle. xd = get(hs,'XData'); yd = get(hs,'YData'); zd = get(hs,'ZData'); delete(hs); % draw this slice: slice(x,y,z,prob,xd,yd,zd); axis tight; title('a slice through the multidimensional Gaussian'); %-- % now plot slices using the peak surface: %-- [xd,yd,zd] = peaks; figure; slice(x,y,z,prob,xd,yd,zd); axis tight; title('slicing with peaks through the multidimensional Gaussian');