全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 经管百科 爱问频道
1490 0
2016-05-28
求大神解释r语言语句,我的目的是生成混合偏正态分布的随机数
这个程序可以吗?具体的生成数是什么怎么看



> ## Do not run
>  
> # set.seed(150520)
>  
> # data(enzyme)
>  
> # x <- enzyme
>  
> # Enzyme1.out <- MixNRMI1(x, Alpha = 1, Beta = 0.007, Gama = 0.5,
>  
> # distr.k = 2, distr.p0 = 2, asigma = 1, bsigma = 1, Meps=0.005,
>  
> # Nit = 5000, Pbi = 0.2)
>  
> # The output of this run is already loaded in the package
>  
> # To show results run the following
>  
> # Data
>  
> data(enzyme)
>  
> x <- enzyme
>  
> data(Enzyme1.out)
>  
> attach(Enzyme1.out)
>  
> # Plotting density estimate + 95% credible interval
>  
> m <- ncol(qx)
>  
> ymax <- max(qx[,m])
>  
> par(mfrow=c(1,1))
>  
> hist(x,probability=TRUE,breaks=20,col=grey(.9),ylim=c(0,ymax))
>  
> lines(xx,qx[,1],lwd=2)
>  
> lines(xx,qx[,2],lty=3,col=4)
>  
> lines(xx,qx[,m],lty=3,col=4)
>  
> # Plotting number of clusters
>  
> par(mfrow=c(2,1))
>  
> plot(R,type="l",main="Trace of R")
>  
> hist(R,breaks=min(R-0.5):max(R+0.5),probability=TRUE)
>  
> # Plotting sigma par(mfrow=c(2,1))
>  
> plot(S,type="l",main="Trace of sigma")
>  
> hist(S,nclass=20,probability=TRUE,main="Histogram of sigma")
>  
> # Plotting u
>  
> par(mfrow=c(2,1))
>  
> plot(U,type="l",main="Trace of U")
>  
> hist(U,nclass=20,probability=TRUE,main="Histogram of U")
>  
> # Plotting cpo
>  
> par(mfrow=c(2,1))
>  
> plot(cpo,main="Scatter plot of CPO's")
>  
> boxplot(cpo,horizontal=TRUE,main="Boxplot of CPO's")
>  
> print(paste('Average log(CPO)=',round(mean(log(cpo)),4)))
[1] "Average log(CPO)= -0.2679"
>  
> print(paste('Median log(CPO)=',round(median(log(cpo)),4)))
[1] "Median log(CPO)= 0.3137"
>  
> detach()
>  
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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