Given that the cdf is not defined under \(x \leq -3\) and \(x > 4\), we only need to concern ourselves with the range \(-3 < x \leq 4\). The generator function would transform to:
\(\therefore\) our variable generator will have the form:
\[x =\begin{cases}6R - 3 & 0 < R \leq \frac{1}{2} \\\sqrt{32R-16} & \frac{1}{2} < R \leq 1\end{cases} \]
Using this model to generate 1000 samples produces the following histogram:
set.seed <- 8675309
R <- runif(1000)
x <- ifelse(R <= 1/2, 6*R-3, 4*sqrt(2*R-1))
nbin <- bigvis::find_width(x, 50)
nbin <- attr(nbin,"n")
ng <- data.frame(x,R)
ggplot(ng, aes(x)) + geom_histogram(bins = nbin) + xlab("x")