I am working on a physical random number generator that is hopefully can generate RN with arbitrary distribution. I am trying to research some applications for this RNG. I have some basic question about Monte Carlo as below:

For example, if I have two correlated events, one has probability distribution A, the other has probability distribution B. These two events are correlated according to a joint probability distribution AB. I want to apply Monte Carlo simulation. I know I need to generate correlated random numbers to run the simulation. Please tell me which step is correct:

a. Do I need to generate independent random numbers for each event with probability dist. A and B separately.

b. When I choose a proper joint density function to generate correlated random numbers, is this true that I only have some known pdf that I can choose from to fit my data the most (such as normal, log normal, sinh-1 , etc.) If it’s true, if I can have a way to generate correlated random numbers with arbitrary pdf, will it be very helpful for Monte Carlo simulation?? Thank you.

  • 1
    $\begingroup$ I have to say the question is not clear to me. but I still try to answer... $\endgroup$
    – Haitao Du
    Jan 24, 2018 at 17:40
  • 2
    $\begingroup$ @hxd It is preferable to ask for clarification. The right answer to a vague or confusing question risks being misinterpreted, which can be worse than offering no answer at all. $\endgroup$
    – whuber
    Jan 24, 2018 at 23:37
  • $\begingroup$ Your question is too unclear at this stage: what do you mean by a (physical) random generator? A machine that produces iid uniform variates? A machine that produces iid simulations from ANY distribution? In one dimension? In several dimensions? And what do you mean by choosing the pdf towards fitting the data? RNGs are not doing estimation but simulation. $\endgroup$
    – Xi'an
    Jan 27, 2018 at 13:07

1 Answer 1


Forward sampling will solve your problem.

$$ P(A,B)=P(A)P(B|A) $$

So, what you need to do is

  • Sample $A$
  • Given $A$, based on $P(B|A)$ sample $B$

Here is a small example in R.

Where $P(A=0)=0.5$, $P(B=0|A=0)=0.3$, $P(B=0|A=1)=0.6$

B= ifelse(A==0,
          sample(0:1, prob = c(0.3,0.7)),
          sample(0:1, prob = c(0.6,0.4)))

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