There are a lot of questions about generating random numbers form both uni-variate and bi-variate distributions. Mathematica has a lot of built in distributions for that purpose. However, I could not do what I wanted to do. I am looking for help.

I want to generate random numbers using built in Mathematica distribution but would like to put some restriction. For example, the following code gives me 2000 random numbers form exponential distribution.

example1=RandomVariate[ExponentialDistribution[0.0067], 2000];

However, I am trying to get 2000 random variables greater than say 20 from exponential distribution. Similarly, the following code gives me 2000 random numbers a form Farlie-Gumbel-Morgenstern copula.

     CopulaDistribution[{"FGM", .34}, {NormalDistribution[0, 1], 
       ExponentialDistribution[0.0067]}], 2000];

However, I want to get 2000 random numbers form Normal distribution between -.02 and .02 or I want random numbers form exponential distribution between 40 and 1000.

Any help is greatly appreciated. Thank you in advance.

  • 2
    $\begingroup$ TruncatedDistribution may be what you are after. $\endgroup$ – Andy Ross Dec 18 '14 at 1:28
  • $\begingroup$ @ Andy, you are right. But I am also expecting some innovative answers, which I always get form this community. $\endgroup$ – ramesh Dec 18 '14 at 2:19
d1 = RandomVariate[ExponentialDistribution[.1], 2000];
d2 = RandomVariate[TruncatedDistribution[{20, 40}, ExponentialDistribution[.1]], 2000];

GraphicsColumn[{Histogram[d1, {1}, PlotRange -> {{0, 72}, {0, 250}}],
                Histogram[d2, {1}, PlotRange -> {{0, 72}, {0, 250}}, AxesOrigin -> {0, 0}]}]

Mathematica graphics

  • $\begingroup$ @ belisarius thank you for taking time to answer my question. This proves that I am a new user of Mathematica. However, I am expecting some more answers so I can play with. Thanks again. $\endgroup$ – ramesh Dec 18 '14 at 2:17
  • $\begingroup$ @rka Feeling comfortable with mathematica takes some time. Be patient and keep trying $\endgroup$ – Dr. belisarius Dec 18 '14 at 2:38

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.