3
$\begingroup$

I have the random variable $X\sim0.5Normal[2,2]+0.5Normal[20,2]$ and I am trying to use Mathematica to simulate, say, 500 points from this distribution. I briefly looked into Monte Carlo Simulation online, but I think they only use examples where the distribution is a "well-known" (i.e. Normal, Beta, etc.).

$\endgroup$

1 Answer 1

4
$\begingroup$
RandomVariate[
 MixtureDistribution[{.5, .5}, 
 NormalDistribution @@@ {{2, 2},{20, 2}}], 
 500]

Histogram[%, 30]

enter image description here

$\endgroup$
1
  • $\begingroup$ Wow thank you so much!!! $\endgroup$
    – J. Campos
    Commented Jun 12, 2017 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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