{"id":116,"date":"2015-06-06T21:23:14","date_gmt":"2015-06-06T20:23:14","guid":{"rendered":"http:\/\/blog.nothinguntoward.eu\/?p=116"},"modified":"2015-06-07T03:57:46","modified_gmt":"2015-06-07T02:57:46","slug":"measuring-capacity-of-constellations","status":"publish","type":"post","link":"https:\/\/nothinguntoward.eu\/?p=116","title":{"rendered":"Measuring Capacity of Constellations"},"content":{"rendered":"<p>Having just the other day finished off my fourth year project (and in doing so, completed my degree! hooray!), I thought I&#8217;d share a little tidbit from it which perhaps might be useful to someone else.<\/p>\n<h2>Background<\/h2>\n<p>Part of the project involved <a href=\"https:\/\/en.wikipedia.org\/wiki\/Quadrature_amplitude_modulation\" target=\"_blank\">QAM<\/a> constellation shaping. That is, moving points around in a constellation &#8212; in this case, to increase the capacity.<br \/>\nA typical QAM constellation would look something like this, shamelessly taken from wikipedia (created by user Splash):<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/qam16.png\" alt=\"qam16\" width=\"200\" height=\"200\" class=\"aligncenter size-full wp-image-118\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/qam16.png 200w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/qam16-150x150.png 150w\" sizes=\"auto, (max-width: 200px) 100vw, 200px\" \/><\/p>\n<p>Whereas here is an example of a shaped constellation which I investigated (coloured by decision region for hard decision decoding):<br \/>\n<a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/64qam-nonsquare.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/64qam-nonsquare-150x150.png\" alt=\"64qam-nonsquare\" width=\"150\" height=\"150\" class=\"aligncenter size-thumbnail wp-image-119\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/64qam-nonsquare-150x150.png 150w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/64qam-nonsquare.png 256w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a><\/p>\n<h2>Capacity<\/h2>\n<p>Comparing these constellations required that I be able to measure their capacities. Here I&#8217;m considering a very simple system:<br \/>\n<a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/system.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/system-300x114.png\" alt=\"system\" width=\"300\" height=\"114\" class=\"aligncenter size-medium wp-image-121\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/system-300x114.png 300w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/system.png 657w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nIt&#8217;s simply a two-dimensional AWGN channel.<\/p>\n<h3>Grid Evaluation<\/h3>\n<p>This is the first method I tried. It didn&#8217;t work very well, and I&#8217;ll explain why.<\/p>\n<p>The capacity of the channel is definied by the mutual information between the input and the output:<br \/>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=I%28Y%3BX%29%3DH%28Y%29-H%28Y%7CX%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='I(Y;X)=H(Y)-H(Y|X)' title='I(Y;X)=H(Y)-H(Y|X)' class='latex' \/><\/p>\n<p>Here, <img src='https:\/\/s0.wp.com\/latex.php?latex=H%28Y%7CX%29%3DH%28X%2BN%7CX%29%3DH%28N%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='H(Y|X)=H(X+N|X)=H(N)' title='H(Y|X)=H(X+N|X)=H(N)' class='latex' \/>, which is simply the entropy of the gaussian distribution and has an <a href=\"http:\/\/en.wikipedia.org\/wiki\/Multivariate_normal_distribution#Entropy\" target=\"_blank\">analytic form<\/a>. In this case, where the gaussian is bivariate and isotropic (that is, the <img src='https:\/\/s0.wp.com\/latex.php?latex=%5CSigma&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\\Sigma' title='\\Sigma' class='latex' \/> matrix is diagonal), this becomes:<br \/>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=1%2Blog%282%5Cpi%5Csigma%5E2%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='1+log(2\\pi\\sigma^2)' title='1+log(2\\pi\\sigma^2)' class='latex' \/><\/p>\n<p><img src='https:\/\/s0.wp.com\/latex.php?latex=H%28Y%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='H(Y)' title='H(Y)' class='latex' \/> on the other hand is a nastier affair &#8211; it&#8217;s the entropy of the noisy signal, or that of a sum of gaussians, <img src='https:\/\/s0.wp.com\/latex.php?latex=-%5Ciint%7Bf_Y%28y%29log%28f_Y%28y%29%29dy%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='-\\iint{f_Y(y)log(f_Y(y))dy}' title='-\\iint{f_Y(y)log(f_Y(y))dy}' class='latex' \/>. This has no closed form so instead the approach I took was to sample <img src='https:\/\/s0.wp.com\/latex.php?latex=f_Y%28y%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f_Y(y)' title='f_Y(y)' class='latex' \/> over a grid, and then sum across it for <img src='https:\/\/s0.wp.com\/latex.php?latex=-%5Csum%7Bf_Y%28y%29log%28f_Y%28y%29%29%7D&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='-\\sum{f_Y(y)log(f_Y(y))}' title='-\\sum{f_Y(y)log(f_Y(y))}' class='latex' \/><\/p>\n<p>This worked quite nicely for some signals, like this one: <a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-good.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-good-300x225.png\" alt=\"pdf-good\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-125\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-good-300x225.png 300w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-good.png 560w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nMost of the probability mass is included in the sampled grid (in fact it sums to 0.9922 here), so the summation serves as a good approximation to the integral.<\/p>\n<p>But, at low SNR, a lot of probability mass spills over the sides:<br \/>\n<a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-bad.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-bad-300x225.png\" alt=\"pdf-bad\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-131\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-bad-300x225.png 300w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/pdf-bad.png 560w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nHere the probability mass inside the grid only sums to 0.6353. This gave utterly meaningless results (as I&#8217;ll show later). I also tried re-scaling the probabilities so that they&#8217;d sum to 1, but ultimately this didn&#8217;t help either.<\/p>\n<h3>Monte Carlo Method<\/h3>\n<p>When I mentioned this to my <a href=\"http:\/\/www2.eng.cam.ac.uk\/~js851\/\" target=\"_blank\">supervisor<\/a>, he mentioned another possible method, using Monte Carlo instead.<\/p>\n<p>First, flip the mutual information expression around and consider it the other way:<br \/>\n<img src='https:\/\/s0.wp.com\/latex.php?latex=I%28X%3BY%29%3DH%28X%29-H%28X%7CY%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='I(X;Y)=H(X)-H(X|Y)' title='I(X;Y)=H(X)-H(X|Y)' class='latex' \/><\/p>\n<p>In this case H(X) is easy &#8212; X is drawn equiprobably from an alphabet size of M. So H(X)=log(M).<\/p>\n<p>H(X|Y) is the tricky part here, but&#8230; we can find it by Monte Carlo.<br \/>\nPick a load of random points from the joint <img src='https:\/\/s0.wp.com\/latex.php?latex=f_%7BXY%7D%28x%2Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='f_{XY}(x,y)' title='f_{XY}(x,y)' class='latex' \/>:<br \/>\n<a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/montecarlo.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/montecarlo-300x225.png\" alt=\"montecarlo\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-133\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/montecarlo-300x225.png 300w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/montecarlo.png 560w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n(This is an example from one of my optimised constellations)<\/p>\n<p>Then for each point, <img src='https:\/\/s0.wp.com\/latex.php?latex=-log%28p_%7BX%7CY%7D%28x%7Cy%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='-log(p_{X|Y}(x|y)' title='-log(p_{X|Y}(x|y)' class='latex' \/> is calculated and the average is taken. Since the process is ergodic, this tends to the expectation, <img src='https:\/\/s0.wp.com\/latex.php?latex=-%5Cmathbb%7BE%7Dlog%28p_%7BX%7CY%7D%28x%7Cy%29%29%3DH%28X%7CY%29&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='-\\mathbb{E}log(p_{X|Y}(x|y))=H(X|Y)' title='-\\mathbb{E}log(p_{X|Y}(x|y))=H(X|Y)' class='latex' \/><\/p>\n<h3>Comparison<\/h3>\n<p>The Monte Carlo method produced much more sensible results:<br \/>\n<a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/allmethods.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/allmethods-300x225.png\" alt=\"allmethods\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-136\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/allmethods-300x225.png 300w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/allmethods-1024x768.png 1024w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/allmethods.png 1200w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Where the grid evaluation method gives meaningless negative capacities at low SNR, the Monte Carlo method gives results tending gracefully to zero.<\/p>\n<p>In hindsight, this could probably have also been done using the original capacity expression, but calculating H(Y) by Monte Carlo&#8230; I&#8217;ll leave that as an exercise for the reader.<\/p>\n<h2>Results<\/h2>\n<p>Just for a little bit of fun, here&#8217;s a few constellations of different orders compared using the method above.<br \/>\n<a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/comparison.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/comparison-300x225.png\" alt=\"comparison\" width=\"300\" height=\"225\" class=\"aligncenter size-medium wp-image-137\" srcset=\"https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/comparison-300x225.png 300w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/comparison-1024x768.png 1024w, https:\/\/nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/comparison.png 1200w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>That&#8217;s about it for this post. I&#8217;ve run out of enthusiasm to write any more. In fact I did about half an hour ago. Maybe it shows. I almost gave up and deleted the post but I figured I&#8217;d finish it in case anyone cared. Do let me know in the comments if you found this useful! It&#8217;s good to know what posts interest people, and it helps for motivation too&#8230;<\/p>\n<p>Here&#8217;s my MATLAB code for the two implementations. It&#8217;s not particularly tidy and the call to mvnpdf breaks in octave, but perhaps it will be useful as a reference for someone:<br \/>\n<a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/ConstellationInformation.m\">ConstellationInformation.m<\/a>, <a href=\"http:\/\/blog.nothinguntoward.eu\/wp-content\/uploads\/2015\/06\/ConstellationInformationMC.m\">ConstellationInformationMC.m<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having just the other day finished off my fourth year project (and in doing so, completed my degree! hooray!), I thought I&#8217;d share a little tidbit from it which perhaps might be useful to someone else. Background Part of the project involved QAM constellation shaping. That is, moving points around in a constellation &#8212; in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=116"}],"version-history":[{"count":16,"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=\/wp\/v2\/posts\/116\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nothinguntoward.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}