楼主: bwnsm
5891 10

[问答] SAS如何生成服从Weibull分布的随机数?有区间限制呢? [推广有奖]

  • 0关注
  • 1粉丝

初中生

95%

还不是VIP/贵宾

-

威望
0
论坛币
738 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
399 点
帖子
5
精华
0
在线时间
33 小时
注册时间
2010-11-26
最后登录
2024-11-1

楼主
bwnsm 在职认证  发表于 2012-3-22 21:07:32 |AI写论文
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
关键词:Weibull分布 Weibull Bull wei 随机数 正态分布 如何

回帖推荐

jingju11 发表于11楼  查看完整内容

其实可以拓展以下而具体的分布倒无所谓。也许可以参考: http://blog.sina.com.cn/s/blog_a3a9263601011qk0.html

本帖被以下文库推荐

沙发
bobguy 发表于 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

藤椅
borjadapeo 发表于 2012-3-22 21:39:09
攒经验 帮顶

板凳
bwnsm 在职认证  发表于 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;

报纸
bwnsm 在职认证  发表于 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/

地板
goldbaodi 发表于 2012-3-23 23:19:05
learning ing ....

7
bobguy 发表于 2012-3-24 10:12:07
(2)如何生成某个区间内的随机数,如服从正态分布,但随机数的范围在a和b之间.

There is now way you can do that. The support of normal distribution is from -00 to +00. But you can let any number from below a be a and any number from u b be b. It is called a truncated normal distribution.

8
ena7777 发表于 2012-3-25 08:52:05
bwnsm 发表于 2012-3-23 10:29
Since the distribution function for the Weibull is closed, you can solve
it for the variable and pl ...
学习了

9
bwnsm 在职认证  发表于 2012-3-25 19:16:34
bobguy 发表于 2012-3-25 11:48
SAS provides such a random function.

Weibull Distribution
谢谢,这个我也试过了,但这个函数只能包含shape和Scale参数,不能输Location参数

10
bobguy 发表于 2012-3-25 21:36:22
bwnsm 发表于 2012-3-25 19:16
谢谢,这个我也试过了,但这个函数只能包含shape和Scale参数,不能输Location参数
Because it does not have a location parameter. For details check the link below,

http://en.wikipedia.org/wiki/Weibull_distribution

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-23 15:05