楼主: fyfzhdsfdx
3438 13

sas宏程序优化和通过模拟搜索控制限 [推广有奖]

11
moyunzheng 发表于 2013-7-6 21:43:38
fyfzhdsfdx 发表于 2013-7-6 20:50
谢啦!顺便问一下您知道怎么用sas产生分段密度函数的随机数吗?问题见上。谢谢。
这个我不知道怎么做,rand(),cdf(),pdf()好像只能使用系统提供的分布,不能使用自定义的分布

你可以参考:Generating random numbers from a piecewise probability distrubution in matlab
http://stackoverflow.com/questio ... trubution-in-matlab

还有这个 piecewisedistribution class
http://www.mathworks.cn/cn/help/ ... tributionclass.html

12
jingju11 发表于 2013-7-6 22:59:42
I just propose a simulation synario:
u~uni(0,1); u0~uni(0.1);
x=(u0<=.5)*log(u) +(u0>.5)*(-3)*log(u). i guess here cdf(x>=0) =cdf(x<0) =1/2 thus equal chance to get positive and negative x.
my math is not good.i forgot how to calculate a comlicated integral...
JingJu

13
fyfzhdsfdx 发表于 2013-7-7 11:03:29
jingju11 发表于 2013-7-6 22:59
I just propose a simulation synario:
u~uni(0,1); u0~uni(0.1);
x=(u0.5)*(-3)*log(u). i guess here c ...
Thanks! I made a mistake last time for calculating its cdf,but now i correct it.


cdf

data a;
do i=1 to 10000;
    y=rand('UNIFORM');
    if y < 0.5 then x=log(2*y);
   else x=-3*log(2-2*y);
    output;
end;
run;

14
fyfzhdsfdx 发表于 2013-7-7 11:04:15
moyunzheng 发表于 2013-7-6 21:43
这个我不知道怎么做,rand(),cdf(),pdf()好像只能使用系统提供的分布,不能使用自定义的分布

你可以参 ...
谢谢您啊,我刚才回复了,您可以参考一下。

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

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