I have the following code I am trying to figure out the distribution which it is sampling from and I need to be able to write a function to generalize sampling for this distn for any N.
set.seed(12032345)
N <- 300
x <- runif(150, 0,1)
x <- c(x, rnorm(150, 0, 1))
x <- sample(x, N, replace = FALSE)
My approach: To me it looks like we have a 50:50 mixture of U(0,1) and N(0,1) and then just sampling from that vector but since N is even would it make sense to generalize it by simulating uniform random variables and determining which half of the (0,1) interval it is in and sampling from U(0,1) if the variate is below 0.5 and sampling from N(0,1) if above?