Implementing Gibbs Sampler on joint distribution $X$ and $N$ where $X$ is continuous and $N$ is discrete

Q Random variables X and N have joint distribution, defined up to a constant of proportionality,

$$f(x,n) \propto \frac{e^{-3x} x^n}{n!} ~,\quad n=0,1,2, \ldots , x>0$$

Implement a Gibbs sampler to sample from this distribution.

I understand in order to implement Gibbs sampler is requires being able to simulate the conditional distributions of $$X$$ and $$N$$ given that the other is fixed.

So far I have:

$$X$$ is a continuous random variable and $$N$$ is a discrete random variable. The conditional distribution of $$X$$ given that $$N = n$$ is proportional to $$e^{-3x} x^n$$ for $$x > 0$$

I tried seeing with if Gamma distribution could be simulated for X and with parameters $${r=n+1}$$ and $$\lambda = 3$$ and I obtained that the conditional distribution would be equal to

$$\frac{ 3^{n+1} e^{-3x} x^n }{ n! }$$

which actually looks like the original proportion with an added $$3^{n+1}$$.

The conditional distribution of $$N$$ given that $$X = n$$ is proportional to $$\frac{ x^n }{ n! } \quad \text{for} \quad n=0,1,2,\ldots$$

This looks like a Poisson distribution with parameter $$\lambda = x$$ but then we would be missing the $$e^{-x}$$ that would appear in this Poisson distribution.

I understand how to complete this in R once I am able to simulate these conditional distributions but I'm stuck on that part. Any insight would be appreciated.

• By that phrase, I just wanted to show what I've done with the question so far which is what is listed below the phrase. The question itself is what I listed above the horizontal line which includes everything that is known about the distribution. If it helps, this question is intended to be done in R but from my understanding I needed to figure out how to simulate the conditional distributions for X and N before coding in R – Niko L Mar 24 at 17:56