我需要在 excel 中生成泊松分布并找到一种方法(逆变换方法)
在 excel 中完成,然后在 sas 中完成(只是为了好玩,所以我不需要快速回答)与ranpoi
sas 函数进行比较。这是我的代码(有效):
data Poisson(keep=mean Poisson PoissonSas);
mean=0.2;
confronta=exp(-mean);
do obs=1 to 100;
found=0;
Poisson=0;
ranuni=1;
do until(found=1);
ranuni=ranuni*ranuni(12547);
if ranuni<confronta then found=1;
else Poisson=Poisson+1;
end;
PoissonSas=ranpoi(012584,mean);
output;
end;
run;
proc means data=Poisson(drop=mean);run;
所以我在两个随机函数中初始化了种子来复制结果。奇怪的是,根据我是使用两种方法还是仅使用其中一种方法(评论另一种方法)提交数据步骤,我会得到不同的结果,但每种类型的提交都会一遍又一遍地得到相同的结果。我总是期待同样的结果!为什么不是这样?(我使用的是 sas 9.3)谢谢!