%% Normalized Histogram
% Generate 1,000 pairs of random numbers and create a bivariate histogram using the 'probability' normalization.

x = randn(1000,1);
y = randn(1000,1);
h = histogram2(x,y,'Normalization','probability')

%
% Compute the total sum of the bar heights. With this normalization, the height of each bar is equal to the probability of selecting an observation within that bin interval, and the heights of all of the bars sum to 1.

S = sum(h.Values(:))

% Copyright 2015 The MathWorks, Inc.