ベータ分布の直感的理解

$[0,1]$区間の一様分布に,もうちょっと凸凹をつけた分布。パラメータは$(p,q)$の二つで,この値で凸凹の様子が変わる。

ちなみに,$p=1,q=1$のとき$[0,1]$の一様分布となる。

ベータ関数

まず、ベータ関数を定義すると
$$B(p,q)=\int_0^1x^{p-1}(1-x)^{q-1}dx, \ p>0,q>0$$
で与えられる

ところが,$p=m,q=n$で,正の整数だとすると,
$$B(m,n)=\frac{(m-1)!(n-1)!}{(m+n-1)!}$$
とあらわすことができる。

ベータ分布

確率密度関数

$$f(x)=\frac{1}{B(p,q)}x^{p-1}(1-x)^{q-1}$$
$p=m,q=n$で,正の整数だとすると,
$$f(x)=\frac{(m+n-1)!}{(m-1)!(n-1)!}x^{m-1}(1-x)^{n-1}$$
と表すことができる。

平均

$$E(x)=\frac{p}{p+q}$$

分散

$$V(x)=\frac{pq}{(p+q)^2(p+q+1)}$$

beta distributions
p=qの場合。=1で一様分布。>1で上に凸、<1で凹となる。

png("beta01.png",height=300,width=400)
fbeta<-function(x){dbeta(x,5,5)}
curve(fbeta,0,1,col="1")
fbeta<-function(x){dbeta(x,2,2)}
curve(fbeta,0,1,col="2",add=T)
fbeta<-function(x){dbeta(x,1,1)}
curve(fbeta,0,1,col="3",add=T)
fbeta<-function(x){dbeta(x,0.5,0.5)}
curve(fbeta,0,1,col="4",add=T)
fbeta<-function(x){dbeta(x,0.1,0.1)}
curve(fbeta,0,1,col="5",add=T)
legend(0,2.5,c("p=5,q=5","p=2,q=2","p=1,q=1","p=0.5,q=0.5","p=0.1,q=0.1"),
cex=0.6,col=1:5,lty=rep(1,5))
dev.off()
beta distributions
p>1,q>1の場合、上に凸となるが、p>qだったら頂点が右寄りに、p<qだったら左よりとなる。
png("beta02.png",height=300,width=400)
fbeta<-function(x){dbeta(x,5,2)}
curve(fbeta,0,1,col="1")
fbeta<-function(x){dbeta(x,3,2)}
curve(fbeta,0,1,col="2",add=T)
fbeta<-function(x){dbeta(x,2,2)}
curve(fbeta,0,1,col="3",add=T)
fbeta<-function(x){dbeta(x,2,3)}
curve(fbeta,0,1,col="4",add=T)
fbeta<-function(x){dbeta(x,2,5)}
curve(fbeta,0,1,col="5",add=T)
legend(0,2.5,c("p=5,q=2","p=3,q=2","p=2,q=2","p=2,q=3","p=2,q=5"),
cex=0.6,col=1:5,lty=rep(1,5))
dev.off()
beta distributions
q=1の場合。p=2で右肩上がりの直線となり、それよりpが大きいほど1に分布が偏る。
png("beta03.png",height=300,width=400)
fbeta<-function(x){dbeta(x,5,1)}
curve(fbeta,0,1,col="1",ylim=c(0,2.5))
fbeta<-function(x){dbeta(x,3,1)}
curve(fbeta,0,1,col="2",add=T)
fbeta<-function(x){dbeta(x,2,1)}
curve(fbeta,0,1,col="3",add=T)
fbeta<-function(x){dbeta(x,1.3,1)}
curve(fbeta,0,1,col="4",add=T)
fbeta<-function(x){dbeta(x,1,1)}
curve(fbeta,0,1,col="5",add=T)
fbeta<-function(x){dbeta(x,0.7,1)}
curve(fbeta,0,1,col="6",add=T)
legend(0,2.5,c("p=5,q=1","p=3,q=1","p=2,q=1","p=1.3,q=1","p=1,q=1","p=0.7,q=1"),
cex=0.6,col=1:6,lty=rep(1,6))
dev.off()
beta distributions
q=2の場合、pが大きいほど、頂点が右の方で高くなる。p=1で右下がりの直線。
png("beta04.png",height=300,width=400)
fbeta<-function(x){dbeta(x,5,2)}
curve(fbeta,0,1,col="1")
fbeta<-function(x){dbeta(x,3,2)}
curve(fbeta,0,1,col="2",add=T)
fbeta<-function(x){dbeta(x,2,2)}
curve(fbeta,0,1,col="3",add=T)
fbeta<-function(x){dbeta(x,1.3,2)}
curve(fbeta,0,1,col="4",add=T)
fbeta<-function(x){dbeta(x,1,2)}
curve(fbeta,0,1,col="5",add=T)
fbeta<-function(x){dbeta(x,0.7,2)}
curve(fbeta,0,1,col="6",add=T)
legend(0,2.5,c("p=5,q=2","p=3,q=2","p=2,q=2","p=1.3,q=2","p=1,q=2","p=0.7,q=2"),
cex=0.6,col=1:6,lty=rep(1,6))