Ratio of Uniforms simulation I am new to simulation methods and am currently learning about the ratio of uniforms method. The problem I am working on is to use the ratio-of-uniform method to create a random number generator in R for a probability density:
$$p(x) \sim \bigg( 1+\frac{x^2}{v} \bigg)^{-(v+1)/2}.$$
The method is as follows.  Define the set:
$$C_h \equiv \Bigg\{ (u,v) \Bigg| 0 \leq u \le \sqrt{\frac{hv}{u}} \Bigg\}.$$
Now perform the following steps:

*

*Generate $u_1,u_2 \sim \text{IID U}(0,1)$;

*Let $u = a u_1$ and $v = b_- + (b_+-b_-) u_2$;

*If $(u,v) \in C_h$ return $v/u$.

I understand how to use the density function and go about the simulation method and code it up in R, but the one part I am currently stuck on is how do we determine what $a$, $b_-$, and $b_+$ are to go from $u_1, u_2$ to $(u,v)$?
 A: I described the approach in a comment above but I'll explicitly do some of the calculations.
The intuition is that $b_{-}$ and $b_{+}$ are lower and upper bounds of a rectangle defined by $U_1, U_2 \sim U(0,1)$ once rescaled. The other sides of the rectangle has height $a$.
To find the values you need to determine $x$ such that $a=sup_x \sqrt{f(x)}$. To do this you can take logarithms and then a derivative and set equal to 0 and solve resulting equation for $x$. Similar approaches can be done for $b_{+}=sup_x x\sqrt{f(x)}$, and $b_{-}=inf_x x\sqrt{f(x)}$.
Worked example for $a$:
$$
\text{log}(f(x)) = -\frac{\nu+1}{4}\left[\text{log}(\nu^2+x^2) - \text{log}(\nu^2)\right],
$$
taking derivative w.r.t. $x$ and equating with zero after some rearranging terms gives,
$$
-\frac{x(\nu+1)}{\nu^2+x^2} = 0.
$$
Which can simplify to $x(\nu+1) =0$ which is true for $x=0$ or $\nu=-1$ but $\nu \geq 1$ as this is the degrees of freedom in a t distribution so $x=0$. Now evaluate
$\sqrt{f(0)}$ to determine the value is $1$. You can verify that $x=0$ is a $supremum$.
Similar but lengthy calculations can be done for $b_{+}$ and $b_{-}$ to determine $x$ values and then evaluated in the respective sup/inf formulae.
This process is very rote but keep in mind that the random variable is being mapped from $x$ space to $(u(x), v(x))$ space via the mapping
$u(x)=\sqrt{f(x)}$ and $v(x) = x\sqrt{f(x)}$, for $x\in \mathbb{R}$.
The $inf$ and $sup$ conditions used are to ensure the minimal bounding rectangle is used in $(u,v)$ space which gives an optimal rejection constant.
