# Bayes Rule for Random Samples?

Suppose I have $M$ samples from unknown distributions $F(X)$ and $F(Z|X)$. Is there a way from these two vectors to get samples of $F(X|Z)$? I understand Bayes rule, but I only know how to apply it to probability density and distribution functions, not random samples from these distributions.

One way is to estimate $F(X)$ and $F(Z \mid X)$ from the samples, use Bayes rule rule to obtain $F(X \mid Z)$, then sample from it.
Or, if you have many samples that are pairs of values $(x, z)$ drawn from the joint distribution $F(X, Z)$, you could 'slice' these to obtain subsamples of $F(X \mid Z)$. For example, if $Z$ is discrete and you're interested in the case $Z=z$, select out all your sampled $X$ values where the corresponding $Z=z$. If $Z$ is continuous, you could define a threshold $\epsilon$, then select out the sampled $X$ values with corresponding $Z$ values $\in [z-\epsilon, z+\epsilon]$. In this case, there's a tradeoff between the accuracy and the number of samples you get.