3
$\begingroup$

My textbook says, for a multivariate case, say $f(x_1, x_2, x_3) = f(x_3 |x_2, x_1)f(x_2|x_1)f(x_1)$, we would simulate a value from the density $f(x_1)$, then using this value simulate from $f(x_2|x_1)$ and then $f(x_3 |x_2, x_1)$..

My question is, how is this simulation from each distribution done in practice? Do we use the inverse transform for each distribution? (assuming these are from standard distributions)

This is supposed to be setting the foundations for Markov chain's and then moving onto MCMC where sampling from more complicated distributions is required.

$\endgroup$
4
$\begingroup$

For what you described, I cannot see any direct relationship with MCMC. What you needed is just a forward sampling.

Here is how it works (suppose we have discrete binary random variables):

  • Step 1. get a sample for $X_1$. In order to do this step, we need to have the distribution $P(X_1)$. (Something like

$$ P(X_1)=\left\{ \begin{array}{ll} 0.2, ~~~~~~ X_1=0\\ 0.8, ~~~~~~ X_1=1\\ \end{array} \right. $$

, and for these numbers you may guess it is very likely to get a $1$ as a sample in this first step).

  • Step 2. get sample for $X_2$. Based on $P(X_2|X_1)$. We need to have the conditional probability table to do this step. (Something like

$$ P(X_2|X_1)=\left\{ \begin{array}{ll} 0.2, ~~~~~~ X_1=0, X_2=0\\ 0.8, ~~~~~~ X_1=0, X_2=1\\ 0, ~~~~~~~~ X_1=1, X_2=0\\ 1, ~~~~~~~~ X_1=1, X_2=1 \end{array} \right. $$

From this example, you will get the a sample of $X_2$ to be 1.).

  • Step 3. get sample for $X_3$. We need to have $P(X_3|X_1,X_2)$. I will ignore the example of the conditional table here (the table will have $2 \times 2 \times 2$ rows).
$\endgroup$
  • $\begingroup$ Hi thanks for answering. This has no direct implications for MCMC yet, however for Inverse transformation I thought if we knew the distribution of say $f(x_1)$ we could find $F(x_1)$ and then use the inverse transformation to generate random samples from $f(x_1)$. With regards to your step 1, how is it actually done? Given we know $P(X_1 = 1)$ and that $P(X_1 =0)$, how do we actually get the random sample? (I hope this makes sense. My confusion lies with how we actually get a random sample from a given distribution) $\endgroup$ – InvestingScientist Feb 16 at 11:38
  • 1
    $\begingroup$ @InvestingScientist, get a uniform random number from 0 to 1, then use CDF of $P(X_1)$, to get the sample. For example, if you are getting 0.6785, then the sample is 0. If you are getting 0.9478, then the sample is 1. $\endgroup$ – Haitao Du Feb 16 at 11:43
  • $\begingroup$ Thank you very much for explaining this $\endgroup$ – InvestingScientist Feb 16 at 11:49
4
$\begingroup$

Once you have the form of the PDF, there are various techniques for sampling. Some easy forms can be handled via Inverse Transform Sampling. Some special forms can be handled via methods special methods, e.g. sampling from normal distribution via Box-Müller. Other general methods exist for PDFs with non-easy/non-special forms (i.e. inverse transform sampling is not possible or easy to employ), such as Rejection sampling, or may others under MCMC topic. The discrete cases are easier to handle as described in @Haitao's answer.

$\endgroup$
  • $\begingroup$ I see, thus far I have only come across the Inverse Transform method, but shortly will cover Gibbs Sampling and Metropolis-Hasting. $\endgroup$ – InvestingScientist Feb 16 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.