I've encountered this question:
Let X ~ Bern(1/2) and let a and b be constants with a < b. Find a simple transformation of X that yields an r.v. that equals a with probability 1 - p and equals b with probability p.
I have been working on this for sometime without answer, is it possible to construct a transformation of X such that a,b,p are all arbitrary? If p is 1/2, then the problem is quite simple, but p is also arbitrary, how can we make this p generic instead of fixing it to 1/2?
Any help is appreciated.
Thanks.
Sketch:
Idea is to write $Y=X+Z$ for a binary random variable $Z$ and choose the conditional distribution $Y|X$ such that $Y\sim $Ber$(p)$.
If $q_1=P(Y=a|X=0)$ and $q_2=P(Y=b|X=1)$ then every choice of $q_1,q_2$ satisfying $q_2-q_1=1-2p$ will then be a conditional distribution satisfying law for $Y$.