Two dimensional histogram
The other day I was doing a Monte Carlo analysis where I had two independent varables and one scalar output. A good visualization for this is a two dimensional histogram. Unfortunatly, these are not directly supported in MATLAB, but thankfully Kangwon Lee has developed one and shared it with the rest of us.
This code came with a good example, and was well documented. These things are often overlooked (Hint, Hint Hint), so I am glad to see they were done this time.
This is the code I used to create the screenshot you see here, mostly a de-generalization of the example with a more intuitive dataset:
N = 160000;
nBins = 30;
z = randn(N, 2);
edges = linspace(-1,1,nBins);
mHist2d = hist2d(z,edges,edges);
edgeLabel = 0.5*(edges(1:end-1)+edges(2:end));
pcolor(edgeLabel, edgeLabel,mHist2d);
colormap(pink); colorbar
title('2d hist of two normally distributed random variables')
评论
要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。