# Generate random numbers for Monte Carlo simulation [closed]

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.

## closed as unclear what you're asking by Xi'an, mdewey, Michael Chernick, kjetil b halvorsen, jbowmanJan 27 '18 at 17:09

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• I have to say the question is not clear to me. but I still try to answer... – Haitao Du Jan 24 '18 at 17:40
• @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. – whuber Jan 24 '18 at 23:37
• 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. – Xi'an Jan 27 '18 at 13:07

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$

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