全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1364 0
2012-08-29
Rejection sampling is an important concept in MC simulation.

Here is an example to illustrate the idea.

The details refer to the link below.

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

****reject sampling ****;
%let target_dist_pdf=pdf('normal',x);
%let sample_dist_pdf=pdf('CAUCHY',x);
%let m=sqrt(2*constant('pi')/CONSTANT('E'));
;
data t1;
  CALL STREAMINIT(123);

  do i=1 to 10000;
    u=rand('unif');
    x=rand('cauchy');
    if u <=&target_dist_pdf/(&m*&sample_dist_pdf) then flag=1;
    else flag=0;

    output;
  end;
  run;

  proc print data=t1(obs=10);
  run;

  proc freq data=t1;
  table flag;
  run;

  proc univariate data=t1;
  var x;
  histogram x/normal;
  where flag=1;
  run;
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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