Since the distribution function for the Weibull is closed, you can solve
it for the variable and plug a uniformally distributed random number in
as an argument. The Weibull distribution is --
F(y) = 1 - exp(-(y-a)/b)**c)
Solving for y gives --
y = [-ln(1-F(y))]**(1/c)+a
So you can generate random Weibull numbers with --
y=(-log(1-ranuni(0)))**(1/c);
(Using 1-ranuni(0) or ranuni(0) is immaterial.)
以上内容来自于
http://listserv.uga.edu/cgi-bin/ ... amp;D=0&P=45818
代码:
data a;
a=2; b=20; c=6;/*a=Location;b=Scale;c=Shape ,in CrystalBall. */
do i=1 to 10000; /* Do 10000 times. ie. generate 10000 random numbers */
x=a+b*(-log(1-uniform(0)))**(1/c); /* Calculate Weibull Random Number. Using 1-ranuni(0) or ranuni(0) is immaterial. */
/*An argument of 0 -- uses your computor clock as a seed. */
/*Functions RANUNI and UNIFORM are identical. Function UNIFORM cannot be utilized as a CALL routine.*/
output;
end;
run;