%% Section 7.1 %% Computing the convolution of two vectors % The MATLAB command *conv* lets you compute the convolution of two % vectors. So, for example, if u, v are given by u = [1/4 1/4 1/2] v = [1/9 2/9 1/9 1/3 1/18 1/6] %% % their convolution is conv(u,v) %% Rolling a die 10 times % Suppose you are interested in the distribution that results from rolling % a die 10 times. The distribution for rolling once is: w = [1/6 1/6 1/6 1/6 1/6 1/6] %% % The distribution for the sum is the convolution of w with itself 9 times. % Here's a way to compute it. p = w; % initialize p. for j = 1:9 p = conv(p,w); % p is the result of convolving w with itself j times end %% % The resulting distribution is: p %% % A good way to make sense of this is to view it as a bar graph. Now % the values of p range from 10 to 60. bar(10:60,p) axis([10 60 0 0.08])