{"id":106,"date":"2004-05-19T17:44:09","date_gmt":"2004-05-19T22:44:09","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=106"},"modified":"2016-05-10T08:51:12","modified_gmt":"2016-05-10T12:51:12","slug":"two-dimensional-histogram","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2004\/05\/19\/two-dimensional-histogram\/","title":{"rendered":"Two dimensional histogram"},"content":{"rendered":"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 <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=1487&amp;objectType=file (link no longer works)\">two dimensional histogram<\/a>. Unfortunatly, these are not directly supported in MATLAB, but thankfully Kangwon Lee has developed one and shared it with the rest of us.\r\n\r\nThis 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.\r\n\r\nThis is the code I used to create the screenshot you see here, mostly a de-generalization of the example with a more intuitive dataset:\r\n\r\nN = 160000;\r\nnBins = 30;\r\nz = randn(N, 2);\r\nedges = linspace(-1,1,nBins);\r\nmHist2d = hist2d(z,edges,edges);\r\n\r\nedgeLabel = 0.5*(edges(1:end-1)+edges(2:end));\r\npcolor(edgeLabel, edgeLabel,mHist2d);\r\ncolormap(pink); colorbar\r\ntitle('2d hist of two normally distributed random variables')\r\n\r\n&nbsp;","protected":false},"excerpt":{"rendered":"<p>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... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2004\/05\/19\/two-dimensional-histogram\/\">read more >><\/a><\/p>","protected":false},"author":68,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/106"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":6949,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/106\/revisions\/6949"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}