This question already has an answer here:
I have a sampling function of:
z = rnorm(n, 0.3, 1)
And would like my variable f to equal 1 if -pi < z_i < pi and equal 0 otherwise.
I'm not sure how to achieve this. My other idea was to use a reject function but this seems overly complicated.