现在的位置: 首页 > 综合 > 正文

离散先验分布

2018年10月22日 ⁄ 综合 ⁄ 共 483字 ⁄ 字号 评论关闭

在《Bayesian computation with r》第21页,作者描绘了一离散分布图形,R代码如下:

p = seq(0.05, 0.95, by = 0.1)
prior = c(1, 5.2, 8, 7.2, 4.6, 2.1, 0.7, 0.1, 0, 0)
prior = prior/sum(prior)
plot(p, prior, type = "h", ylab="Prior Probability")

粗略的用SAS表达:

data test;
  input prior p @@;
  retain sprior 0;
  sprior=prior+sprior;
  cards;
1 0.05 5.2 0.15 8 0.25
7.2 0.35 4.6 0.45 2.1 0.55
0.7 0.65 0.1 0.75 0 0.85 0 0.95
;
run;
proc sql;
   create table test1 as
    select prior,p,
        prior/max(sprior) as pprior
    from test;
quit;
symbol i=needle;
proc gplot data=test1;
   plot pprior*p/overlay;
run;

 

抱歉!评论已关闭.