Problem.5 Given the following cdf for a continuous variable with range from -3 to 4, develop a generator for the variable, generate 1000 values, and plot a histogram.
F(x)= 0, x <= -3 F(x)= 1/2+ x/6, -3 <= 0 F(x)= 1/2 + (x^2/32 ), 0
R= 1/2 + x/6 -> 6(R-1/2)
R = 1/2 + (x^2 / 32) -> 4(sqrt(2R-1))
set.seed(66)
R <- runif(1000, 0.0,1)
v <- ifelse (R <= 0.5, 6*R-3, 4*sqrt(2*R-1))
## Warning in sqrt(2 * R - 1): NaNs produced
hist(v)