全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
5924 10
2012-03-22
悬赏 20 个论坛币 已解决
各位高手,有两个问题请教:

(1)SAS如何生成服从Weibull分布的随机数(已解决,见下面回帖,第二个问题继续寻求答案);

(2)如何生成某个区间内的随机数,如服从正态分布,但随机数的范围在a和b之间;

谢谢各位!

最佳答案

bobguy 查看完整内容

SAS provides such a random function. Weibull Distribution x = RAND('WEIBULL',a,b) Arguments x is an observation from the distribution with the following probability density function: Range:x ≥ 0 a is a numeric shape parameter. Range:a > 0 b is a numeric scale parameter. Range:b > 0
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-3-22 21:07:33
bwnsm 发表于 2012-3-23 10:29
Since the distribution function for the Weibull is closed, you can solve
it for the variable and pl ...
SAS provides such a random function.

Weibull Distribution
x = RAND('WEIBULL',a,b)
Arguments
x
is an observation from the distribution with the following probability density function:

Range:x ≥ 0
a
is a numeric shape parameter.
Range:a > 0
b
is a numeric scale parameter.
Range:b > 0
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-22 21:39:09
攒经验 帮顶
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-23 10:29:18
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;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-23 10:59:59
生成某个区间内的随机数代码:

data work.trunc_norm;
mean=0;
sd=1;
max=2;
min=-2;
do i = 1 to 10000;
random=max+1;
do while (random<min or random>max);
random=rannor(-1)*sd+mean;
end;
output;
end;
run;

参考:http://confounding.net/2010/12/0 ... ormal-distribution/
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2012-3-23 23:19:05
learning ing ....
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群