% eda03_01
% Illustrate the calculatioon of the mode of a
% distribution p(d)

% Illustrative distribution p(d)
Dd = 1.0;                   % sampling interval
d = Dd*[0:14]' + 0.5*Dd;    % vector of evenly-spaced d's
p = [5.00, 15.00, 10.00, 10.00, 10.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00, 5.00]';

% normalize fistribution so its integral is unity
% note element-wise division
p = p./(Dd*sum(p));

% note that i is the row index at which the maximum pmax occurs
[pmax, i] = max(p);
themode = d(i);

% output to command window
disp(sprintf('mode = %f', themode));