<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-3/"></div></div><div><a data-url="https://www.r-bloggers.com/ratio-of-uniforms-3/" data-counturl="https://www.r-bloggers.com/ratio-of-uniforms-3/" data-count="horizontal" data-text="ratio-of-uniforms [#3]" 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/11/04/ratio-of-uniforms-3/"> 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>B</strong>eing still puzzled (!) by the <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/2016/10/24/ratio-of-uniforms/">ratio-of-uniform approach</a>, mostly failing to catch its relevance for either standard distributions in a era when computing a cosine or an exponential is negligible, or non-standard distributions for which computing bounds and boundaries is out-of-reach, I kept searching for solutions that would include unbounded densities and still produce compact boxes, as this seems essential for accept-reject simulation if not for slice sampling. And after exploring some dead-ends (in tune with running in <a target="_blank" rel="nofollow" href="https://xianblog.wordpress.com/2016/10/26/a-venezia-esobe-2016/">Venezia</a>!), I came upon the case of the generalised logistic transform</p>
<p><img title="h(\omega)=\omega^a/(1+\omega^a)" alt="h(\omega)=\omega^a/(1+\omega^a)" class="latex" src="https://s0.wp.com/latex.php?latex=h%28%5Comega%29%3D%5Comega%5Ea%2F%281%2B%5Comega%5Ea%29&bg=000000&%23038;fg=B0B0B0&%23038;s=0"></p>
<p>which ensures that the [ratio-of-almost-uniform] set I defined in my slides last week</p>
<p><img title="\mathfrak{H}=\left\{(u,v);\ 0\le u\le h(f(v/g(u))\right\}" alt="\mathfrak{H}=\left\{(u,v);\ 0\le u\le h(f(v/g(u))\right\}" class="latex" src="https://s0.wp.com/latex.php?latex=%5Cmathfrak%7BH%7D%3D%5Cleft%5C%7B%28u%2Cv%29%3B%5C+0%5Cle+u%5Cle+h%28f%28v%2Fg%28u%29%29%5Cright%5C%7D&bg=000000&%23038;fg=B0B0B0&%23038;s=0"></p>
<p>is bounded in u. Since the transform g is the derivative of the inverse of h (!),</p>
<p><img title="g(y)=a^{-1}y^{(1-a)/a}/(1-y)^{(1-3a)/a}" alt="g(y)=a^{-1}y^{(1-a)/a}/(1-y)^{(1-3a)/a}" class="latex" src="https://s0.wp.com/latex.php?latex=g%28y%29%3Da%5E%7B-1%7Dy%5E%7B%281-a%29%2Fa%7D%2F%281-y%29%5E%7B%281-3a%29%2Fa%7D&bg=000000&%23038;fg=B0B0B0&%23038;s=0"></p>
<p>the parametrisation of the boundary of <em><strong>H</strong></em> is</p>
<p><img title="u(x)=f(x)^a/(1+f(x)^a)\ v(x)=a^{-1}xf(x)^{(a-1)/a}(1+f(x)^a)^2" alt="u(x)=f(x)^a/(1+f(x)^a)\ v(x)=a^{-1}xf(x)^{(a-1)/a}(1+f(x)^a)^2" class="latex" src="https://s0.wp.com/latex.php?latex=u%28x%29%3Df%28x%29%5Ea%2F%281%2Bf%28x%29%5Ea%29%5C+v%28x%29%3Da%5E%7B-1%7Dxf%28x%29%5E%7B%28a-1%29%2Fa%7D%281%2Bf%28x%29%5Ea%29%5E2&bg=000000&%23038;fg=B0B0B0&%23038;s=0"></p>
<p>which means it remains bounded if (a) a≤1 [to ensure boundedness at infinity] and (b) the limit of v(x) at zero [where I assume the asymptote stands] is bounded. Meaning</p>
<p><img title="\lim_{x\to 0} xf(x)^{2a+1/a-1}&lt;\infty" alt="\lim_{x\to 0} xf(x)^{2a+1/a-1}&lt;\infty" class="latex" src="https://s0.wp.com/latex.php?latex=%5Clim_%7Bx%5Cto+0%7D+xf%28x%29%5E%7B2a%2B1%2Fa-1%7D%3C%5Cinfty&bg=000000&%23038;fg=B0B0B0&%23038;s=0"></p>
<p>For instance, this holds for Gamma distributions with shape parameter larger than ½…</p>
<p>Working a wee bit more on the problem led me to realise that resorting an arbitrary cdf Φ instead of the logistic one could solve the problem for most distributions, including all Gammas. Indeed, the boundary of <em><strong>H</strong></em> is now</p>
<p><img title="u(x)=\Phi(f(x))^a\ v(x)=a^{-1}xf(x)^{(a-1)/a}/\varphi(f(x))" alt="u(x)=\Phi(f(x))^a\ v(x)=a^{-1}xf(x)^{(a-1)/a}/\varphi(f(x))" class="latex" src="https://s0.wp.com/latex.php?latex=u%28x%29%3D%5CPhi%28f%28x%29%29%5Ea%5C+v%28x%29%3Da%5E%7B-1%7Dxf%28x%29%5E%7B%28a-1%29%2Fa%7D%2F%5Cvarphi%28f%28x%29%29&bg=000000&%23038;fg=B0B0B0&%23038;s=0"></p>
<p>which means it remains bounded if φ has very heavy tails, like 1/x². To handle the explosion when x=0. And an asymptote itself at zero, to handle the limit at infinity when f(x) goes to zero.</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/gamma-generator/">Gamma generator</a>, <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/31867/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/xianblog.wordpress.com/31867/" 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-3/"></div></div><div><a data-url="https://www.r-bloggers.com/ratio-of-uniforms-3/" data-counturl="https://www.r-bloggers.com/ratio-of-uniforms-3/" data-count="vertical" data-text="ratio-of-uniforms [#3]" 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/11/04/ratio-of-uniforms-3/"> 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/r3I9YVD50QU"></a></div>