Rank: 72897 based on downloads (last 30 days) and 0 files submitted
photo

Matthias Fripp

E-mail

Personal Profile:

Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Matthias View all
Updated File Comments Rating
19 Aug 2010 Empirical Bivariate CDF Estimating Empirical Bivariate Cumulative Density Function Author: Taesam Lee

I found this page while looking for a hint on how to calculate an empirical 2-D CDF (cumulative density) from an empirical bivariate PDF (density) in Matlab. I found a nested loop in your code that does this, but subsequently found a much faster way. You may want to try this instead of the i1 and i2 loops in your code: biv_CDF=cumsum(cumsum(N,1),2)/nL

31 Jul 2010 N-dimensional histogram Compute n-dimensional histogram Author: Bruno Luong

About plotting the results:

Jaclyn, if you just want bars plotted for the pairwise densities of two variables (i.e., a plot with x and y axes corresponding to values of your variables, and vertical bars on the x,y grid, corresponding to the counts for each 2D bin), you can get that with hist3().

Will, if you want to plot weights for 3 variables as varying sizes of bubbles on an x,y,z grid, you can do something like this:

% get the histogram
[count edges mid loc] = histcn(vals);

% make a grid for plotting
[X Y Z]=ndgrid(edges{1}, edges{2}, edges{3});
X=X(:); Y=Y(:); Z=Z(:);

% calculate sizes so the most dense cell gets a value of 100
% also convert from volume to "area" (as if drawing a sphere with
% the right volume and cross-sectional area s)
s_scale = 100/(max(count(:))^(2/3));
s = count(:).^(2/3) * s_scale;
% convert any zeros to small numbers for scatter3
s(s==0)=realmin;

% plot the densities
fh=figure();
set(fh, 'Renderer', 'OpenGL'); % faster drawing
scatter3(X, Y, Z, s, 'filled');

Contact us at files@mathworks.com