<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/ratio-of-uniforms/"></div></div><div><a data-url="https://www.r-bloggers.com/ratio-of-uniforms/" data-counturl="https://www.r-bloggers.com/ratio-of-uniforms/" data-count="horizontal" data-text="ratio-of-uniforms" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://xianblog.wordpress.com/2016/10/24/ratio-of-uniforms/"> R – Xi'an's Og</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><strong><a target="_blank" rel="nofollow" href="https://i2.wp.com/images-na.ssl-images-amazon.com/images/I/41knkIXE%2BoL._SX330_BO1,204,203,200_.jpg?ssl=1"><img alt="" src="https://i2.wp.com/images-na.ssl-images-amazon.com/images/I/41knkIXE%2BoL._SX330_BO1,204,203,200_.jpg?resize=222%2C333&ssl=1" data-recalc-dims="1"></a>O</strong>ne approach to random number generation that had always intrigued me is Kinderman and Monahan’s (1977) ratio-of-uniform method. The method is based on the result that the uniform distribution on the set A of (u,v)’s in <strong>R⁺</strong>x<strong>X</strong> such that</p>
<p>0≤u²≤<strong>ƒ</strong>(v/u)</p>
<p>induces the distribution with density proportional to <strong>ƒ</strong> on V/U. Hence the name. The proof is straightforward and the result can be seen as a consequence of the fundamental lemma of simulation, namely that simulating from the uniform distribution on the set B of (w,x)’s in <strong>R⁺</strong>x<strong>X</strong> such that</p>
<p>0≤w≤<strong>ƒ</strong>(x)</p>
<p>induces the marginal distribution with density proportional to <strong>ƒ</strong> on X. There is no mathematical issue with this result, but I have difficulties with picturing the construction of efficient random number generators based on this principle.</p>
<p><a target="_blank" rel="nofollow" href="https://i1.wp.com/xianblog.files.wordpress.com/2016/10/ratouni.jpg?ssl=1"><img sizes="(max-width: 333px) 100vw, 333px" alt="ratouni" class="wp-image-31766" src="https://i1.wp.com/xianblog.files.wordpress.com/2016/10/ratouni.jpg?resize=333%2C333&ssl=1" data-recalc-dims="1"></a>I thus took the opportunity of the second season of [the Warwick reading group on] <a target="_blank" rel="nofollow" href="http://amzn.to/2dRMdwq">Non-uniform random variate generation</a> to look anew at this approach. (Note that the book is freely available on <a target="_blank" rel="nofollow" href="http://www.nrbook.com/devroye/">Luc Devroye’s website</a>.) The first thing I considered is the shape of the set A. Which has nothing intuitive about it! Luc then mentions (p.195) that the boundary of A is given by</p>
<p>u(x)=√<strong>ƒ</strong>(x),v(x)=x√<strong>ƒ</strong>(x)</p>
<p>which then leads to bounding both <strong>ƒ</strong> and x→x²<strong>ƒ</strong>(x) to create a box around A and an accept-reject strategy, but I have trouble with this result without making further assumptions about <strong>ƒ</strong>… Using a two component normal mixture as a benchmark, I found bounds on u(.) and v(.) and simulated a large number of points within the box to end up with the above graph that indeed the accepted (u,v)’s were within this boundary. And the same holds with a more ambitious mixture:</p>
<p><a target="_blank" rel="nofollow" href="https://i2.wp.com/xianblog.files.wordpress.com/2016/10/bagpiiipe.jpg?ssl=1"><img sizes="(max-width: 386px) 100vw, 386px" alt="bagpiiipe" class="wp-image-31768" src="https://i2.wp.com/xianblog.files.wordpress.com/2016/10/bagpiiipe.jpg?resize=386%2C386&ssl=1" data-recalc-dims="1"></a></p>
<p>Filed under: <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/category/books/">Books</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/category/pictures/">pictures</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/category/statistics/r-statistics/">R</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/category/statistics/">Statistics</a> Tagged: <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/luc-devroye/">Luc Devroye</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/non-uniform-random-variate-generation/">Non-Uniform Random Variate Generation</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/random-number-generation/">random number generation</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/ratio-of-uniform-algorithm/">ratio of uniform algorithm</a>, <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/tag/university-of-warwick/">University of Warwick</a> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xianblog.wordpress.com/31765/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/xianblog.wordpress.com/31765/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/ratio-of-uniforms/"></div></div><div><a data-url="https://www.r-bloggers.com/ratio-of-uniforms/" data-counturl="https://www.r-bloggers.com/ratio-of-uniforms/" data-count="vertical" data-text="ratio-of-uniforms" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://xianblog.wordpress.com/2016/10/24/ratio-of-uniforms/"> R – Xi'an's Og</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/xwjfKTivzWI"></a></div>