beta分布的R语言实例
首先,我们可以画一个beta分布的概率密度函数。
set.seed(1)
x<-seq(0,1,length.out=10000)
plot(0,0,main='probability density function',xlim=c(0,1),ylim=c(0,2.5),ylab='PDF')
lines(x,dbeta(x,0.5,0.5),col='red')
lines(x,dbeta(x,1,2),col='green')
lines(x,dbeta(x,2,2),col='pink')
lines(x,dbeta(x,2,5),col='orange')
lines(x,dbeta(x,1,3),col='blue')
lines(x,dbeta(x,5,1),col='black')
legend('top',legend=c('α=0.5,β=0.5','α=1,β=2','α=2,β=2','α=2,β=5','α=1,β=3','α=5,β=1'),col=c('red','green','pink','orange','blue','black'),lwd=1)
我们再来画一个beta分布的累计概率密度函数
set.seed(1)
x<-seq(0,1,length.out=10000)
plot(0,0,main='cumulative distribution function',xlim=c(0,1),ylim=c(0,1),ylab='PDF')
lines(x,pbeta(x,0.5,0.5),col='red')
lines(x,pbeta(x,1,2),col='green')
lines(x,pbeta(x,2,2),col='pink')
lines(x,pbeta(x,2,5),col='orange')
lines(x,pbeta(x,1,3),col='blue')
lines(x,pbeta(x,5,1),col='black')
legend('topleft',legend=c('α=0.5,β=0.5','α=1,β=2','α=2,β=2','α=2,β=5','α=1,β=3','α=5,β=1'),col=c('red','green','pink','orange','blue','black'),lwd=1)
来源1:Dirichlet Process : Tutorial and Practical Course,Yee Whye Teh
来源2:Dirichlet Processes:A gentle tutorial, Khalid El-Arini
来源3:https://en.wikipedia.org/wiki/Dirichlet_distribution
来源4:https://en.wikipedia.org/wiki/Beta_distribution
来源5:LDA 数学八卦,靳志辉
来源6:Dirichelt Process:徐亦达的优酷视频:http://i.youku.com/i/UMzIzNDgxNTg5Ng==