{"id":1517,"date":"2022-11-25T23:30:00","date_gmt":"2022-11-26T04:30:00","guid":{"rendered":"http:\/\/aristotle2digital.blogwyrm.com\/?p=1517"},"modified":"2022-11-26T20:45:57","modified_gmt":"2022-11-27T01:45:57","slug":"multivariate-gaussian-part-2","status":"publish","type":"post","link":"https:\/\/aristotle2digital.blogwyrm.com\/?p=1517","title":{"rendered":"Multivariate Gaussian &#8211; Part 2"},"content":{"rendered":"\n<p>This month&#8217;s blog continues the exploration begun in the last installment, which covered how to evaluate and normalize multivariate Gaussian distributions.&nbsp; The focus here will be on evaluating moments of these distributions.&nbsp; As a reminder, the prototype example is from Section 1.2 of Brezin&#8217;s text Introduction to Statistical Field Theory, where he posed the following toy problem for the reader:<\/p>\n\n\n\n<p>\\[ E[x^4 y^2] = \\frac{1}{N} \\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} x^4 y^2 e^{-(x^2 + xy + 2 y^2)} \\; , \\]<\/p>\n\n\n\n<p>where the normalization constant $N$, the value of the integral with only the exponential term kept, is found, as described in the last post, by re-expressing the exponent of the integrand as a quadratic form $r^T A r\/2$ (where $r$ presents the independent variables as a column array) and then expressing the value of the integral in terms of the determinant of the matrix $A$: $N = (2 \\pi)^{(n\/2)}\/\\sqrt{\\det{A}}$.&nbsp; Note: for reasons that will become apparent below, the scaling of the quadratic form was changed with the introduction of a one-half in the exponent.&nbsp; Under this scaling $A \\rightarrow A\/2$ and $\\det{A} \\rightarrow \\det{A}\/2^n$, where $n$ is the dimensionality of the space.<\/p>\n\n\n\n<p>To evaluate the moments, we first extend the exponent by &#8216;coupling&#8217; it to an $n$-dimensional &#8216;source&#8217; $b$ via the introduction of the term $b^T r$ in the exponent.&nbsp; The integrand becomes:<\/p>\n\n\n\n<p>\\[ e^{-r^T A r\/2 + b^T r} . \\]<\/p>\n\n\n\n<p>The strategy for manipulating this term into one we can deal with is akin to usual &#8216;complete the square&#8217; approach in one dimension but generalized.&nbsp; We start by defining a new variable<\/p>\n\n\n\n<p>\\[ s = r \\, &#8211; A^{-1} b \\; .\\]<\/p>\n\n\n\n<p>Regardless of what $b$ is (real positive, real negative, complex, etc.) the original limits on the $r_i \\in (-\\infty,\\infty)$ carry over to $s$.&nbsp; Likewise, the measures of the two variables are related by $d^ns =d^nr$.&nbsp; In terms of the integral, this definition simply moves the origin of the $s$ relative to the $r$ by an amount $A^{-1}b$, which results in no change since the range is infinite.<\/p>\n\n\n\n<p>Let&#8217;s manipulate the first term in the exponent step-by-step.&nbsp; Expanding the right side gives<\/p>\n\n\n\n<p>\\[ r^T A (s + A^{-1} b) = r^T A s + r^T b \\; .\\]<\/p>\n\n\n\n<p>Since $A$ is symmetric, its inverse is too, $\\left( A^{-1} \\right)^T = A^{-1}$ and this observation allows us to now expand the first term side, giving<\/p>\n\n\n\n<p>\\[ (s^T + b^T A^{-1} ) A s + r^T b = s^T A s + b^T s + r^T b \\; . \\]<\/p>\n\n\n\n<p>Next note that $b^T r = b_i r_i = r^T b$ (summation implied) and then substitute these pieces into the original expression to get<\/p>\n\n\n\n<p>\\[ -r^T A r\/2 &#8211; b^T r = -( s^T A s + b^T s + b^T r)\/2 + b^T r \\\\ = -s^T A s + b^T ( r &#8211; s )\/2&nbsp; \\; . \\]<\/p>\n\n\n\n<p>Finally, using the definition of $s$ the last term can be simplified to eliminate both $r$ and $s$, leaving<\/p>\n\n\n\n<p>\\[ -r^T A r = -s^T A s + b^T A^{-1} b \/2 \\; .\\]<\/p>\n\n\n\n<p>The original integral $I = \\int d^n r \\exp{(-r^T A r\/2 + b^T r)}$ now becomes<\/p>\n\n\n\n<p>\\[ I = e^{-b^T A^{-1} b\/2} \\int d^n s \\, e^{-s^T A s} = e^{-b^T A^{-1} b\/2} \\, \\frac{(2 \\pi)^{(n\/2)}}{\\sqrt{\\det{A}}} \\; . \\]<\/p>\n\n\n\n<p>This result provides us with the mechanism to evaluate any multivariate moment of the distribution by differentiating with respect to $b$ and then setting $b=0$ afterwards.&nbsp;<\/p>\n\n\n\n<p>For instance, if $r^T = [x,y]$, then the moment of $x$ with respect to the original distribution of the Brezin problem is&nbsp;<\/p>\n\n\n\n<p>\\[ E[x] = \\frac{1}{N} \\int_{-\\infty}^{\\infty} \\int_{-\\infty}^{\\infty} x e^{-(x^2 + xy + 2 y^2)} \\; , \\]<\/p>\n\n\n\n<p>where $N = 2\\pi\/\\sqrt{\\det{A}}$.<\/p>\n\n\n\n<p>Our expectation is, by symmetry, that this integral is zero.&nbsp; We can confirm that by noting that first that the expectation value is given by<\/p>\n\n\n\n<p>\\[ E[x;b] = \\frac{\\partial}{\\partial b_x } \\frac{1}{N} \\int dx \\, dy \\, e^{-r^T A r + b_x x + b_y y} \\\\ = \\frac{1}{N} \\int dx \\, dy \\, x e^{-r^T A r + b_x x + b_y y} \\; ,\\]<\/p>\n\n\n\n<p>where the notation $E[x;b]$ is adopted to remind us that we have yet to set $b=0$.<\/p>\n\n\n\n<p>Substituting the result from above gives<\/p>\n\n\n\n<p>&nbsp;\\[ E[x] = \\left. \\left( \\frac{\\partial}{\\partial b_x } e^{b^T A^{-1} b\/2} \\right) \\right|_{b=0} \\\\ =  \\left. \\frac{\\partial}{\\partial b_x} (b^T A^{-1} b)\/2 \\right|_{b=0} \\; , \\]<\/p>\n\n\n\n<p>&nbsp;where, in the last step, we used $\\left. e^{b^T A^{-1} b} \\right|_{b=0} = 1$.<\/p>\n\n\n\n<p>At this point it is easier to switch to index notation when evaluating the derivative to get<\/p>\n\n\n\n<p>\\[ E[x] = \\left. \\frac{\\partial}{\\partial b_x} (b_i (A^{-1})_{ij} b_j\/2) \\right|_{b=0} = \\left. (A^{-1})_{xj} b_j \\right|_{b=0} = 0 \\; ,\\]<\/p>\n\n\n\n<p>where rationale for the scaling by $1\/2$ now becomes obvious.<\/p>\n\n\n\n<p>At this point, we are ready to tackle the original problem.&nbsp; For now, we will use a symbolic algebra system to calculate the required derivatives, deferring until the next post some of the techniques needed to simplify and generalize these steps.&nbsp; In addition, for notational simplicity, we assign $B = A^{-1}$.&nbsp;<\/p>\n\n\n\n<p>Brezin&#8217;s problem requires that<\/p>\n\n\n\n<p>\\[ A = \\left[ \\begin{array}{cc} 2 &amp; 1 \\\\ 1 &amp; 4 \\end{array} \\right] \\; \\]<\/p>\n\n\n\n<p>and that<\/p>\n\n\n\n<p>\\[ B = A^{-1} = \\frac{1}{7} \\left[&nbsp; \\begin{array}{cc} 4 &amp; -1 \\\\ -1 &amp; 2 \\end{array} \\right] \\; .\\]<\/p>\n\n\n\n<p>The required moment is related to the derivatives of $b^T B b$ as<\/p>\n\n\n\n<p>\\[ E[x^4y^2] = \\left. \\frac{\\partial^6}{\\partial b_x^4 \\partial b_y^2 } e^{b^T B b\/2} \\right|_{b=0} = 3 B_{xx}^2 B_{yy} + 12 B_{xx} B_{xy}^2 \\; . \\]<\/p>\n\n\n\n<p>Substituting from above yields<\/p>\n\n\n\n<p>\\[ E[x^4 y^2] = 3 \\left( \\frac{4}{7} \\right)^2 \\frac{2}{7} + 12 \\frac{4}{7} \\left( \\frac{-1}{7} \\right)^2 \\; , \\]<\/p>\n\n\n\n<p>which evaluates to<\/p>\n\n\n\n<p>\\[ E[x^4 y^2] = \\frac{96}{343} + \\frac{48}{343} = \\frac{144}{343} \\; . \\]<\/p>\n\n\n\n<p>\u00a0A brute force Monte Carlo evaluation gives the estimate $E[x^4 y^2] = 0.4208196$ compared with the exact decimal representation of $0.4198251$, a $0.24\\%$ error, which is in excellent agreement.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This month&#8217;s blog continues the exploration begun in the last installment, which covered how to evaluate and normalize multivariate Gaussian distributions.&nbsp; The focus here will be on evaluating moments of&#8230; <a class=\"read-more-button\" href=\"https:\/\/aristotle2digital.blogwyrm.com\/?p=1517\">Read more &gt;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1517","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1517"}],"version-history":[{"count":7,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1517\/revisions"}],"predecessor-version":[{"id":1526,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1517\/revisions\/1526"}],"wp:attachment":[{"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aristotle2digital.blogwyrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}