# how to sample from a conditional Bernoulli distribution

Given a variable $$x_t \in \{0,1\}$$, then we sample $$x_{t+1}$$ in the following way $$x_{t+1} = x_{tmp} x_t + (1-x_{tmp})(1-x_t ), \ x_{tmp} \sim Ber(x_{tmp};p).$$ Does $$x_{t+1}$$ follows the distribution $$Ber(x_{t+1} ; p^{x_{t}}(1-p)^{1 - x_{t}})$$? If so, how to prove it? Or not, what is the distribution of $$p(x_{t+1}|x_{t})$$?

• What does "$x$" mean in "$Ber(x;p)$"?? Unless you get your notation absolutely right, we have to believe your question might be ambiguous.
– whuber
Commented Jul 30, 2021 at 14:21
• @whuber sorry to confuse you. I have edited the question. Actually it is $Ber(x_{tmp}; p)$
– jzin
Commented Jul 31, 2021 at 7:06

You have that the PMF of $$x_{t+1}|x_{t}$$. From what you've given $$x_{t+1}|x_{t}$$ can only take the values 0 and 1.

Let's find the probability of $$x_{t+1}=1$$ which can be realized in two possible ways,

$$p(x_{t+1}=1|x_{t}=1)=p(x_{tmp})=p$$ and $$p(x_{t+1}=1|x_{t}=0)=p(1-x_{tmp})=1-p$$.

Those two cases can be merged irrelevant of the specific value of $$x_{t}$$ as,

$$p(x_{t+1}=1|x_{t})=p^{x_{t}}(1-p)^{1-x_{t}}$$

Hence, as you noted the distribution is

$$x_{t+1}|x_{t}\sim Bern(x_{t+1};p^{x_{t}}(1-p)^{1-x_{t}})$$