random number generator for different distribution

68 views
Skip to first unread message

Rupsana Parveen

unread,
May 25, 2017, 12:44:04 PM5/25/17
to AMPL Modeling Language

Hi Dr. Bob,


Initially I had created random numbers for 5 outcomes where they all follow normal distribution with following parameters: 


#dat file

set outcome := 1 2 3 4 5;

set err1_mean := 0.011099 0.017007 0.076378 -0.00608 -0.00609;

set err1_std := 0.829445 0.699492 0.687686 0.679408 1.090222;

 

#mod file

set outcome ordered;

param nsample := 25;

set err1_mean ordered;

set err1_std ordered;

param err1{i in outcome, j in 1..nsample} = Normal (member(ord(i),err1_mean), member(ord(i),err1_std));


 

Now, they all follow different distribution with following expressions:  


Outcome1 ::     Weibull Distribution:  -2.6 + WEIB(2.88, 4.21)

Outcome2 ::     Lognormal   Distribution: -1.81 + LOGN(1.89, 0.707)

Outcome3 ::     Erlang Distribution: -2 + ERLA(0.253, 8)

Outcome4 ::     Gamma Distribution: -2.89 + GAMM(0.197, 15.2)

Outcome5 ::     Triangular Distribution: TRIA(-2.91, 0.635, 2.83)



My question is-  how to generate random numbers for Weibull, Lognormal, Erlang, Gamma, and Triangular distribution in AMPL?   


Thanks

Robert Fourer

unread,
May 26, 2017, 12:57:23 PM5/26/17
to am...@googlegroups.com
See http://ampl.com/resources/extended-function-library/ for instructions on AMPL's Extended Function Library. It provides functions that return random variates from the Weibull, Lognormal, and Gamma distributions. The Erlang distribution is a special case of the Gamma in which the first parameter is an integer. The random variates from the Triangular distribution are easily computed from Uniform random variates -- see for instance the Wikipedia entry for the Triangular distribution.

Bob Fourer
am...@googlegroups.com

=======
Reply all
Reply to author
Forward
0 new messages