私はPolya Urnモデルを構築しようとしています。 2色はうまく行きましたが、3色では問題が発生しました。複数(> 2)色のポリアールプロセスをモデル化するにはどうすればよいですか?
ndraws<-1000; nexps<-2000; Distribution.yellow<-matrix(0,ndraws,1); for (k in 1:nexps){
red<- 1;
yellow<- 1;
blue<-1 ;
for (n in 1:ndraws){
drawn<-sample(0:2,size=1,prob=c(red,yellow,blue)/(red+yellow +blue))
red<-?? ;
blue<-?? ;
yellow<-?? ;
}
Distribution.yellow[k]<-yellow/(red+yellow+blue) }
私の問題は、このコード行を変換することにある:骨壷に追加し、それぞれの余分なボールの中へ
drawn<-sample(0:2,size=1,prob=c(red,yellow,blue)/(red+yellow +blue))
を。 (したがって、疑問符)。
drawn<-sample(0:1,size=1,prob=c(red,blue)/(red+blue))
red<-red+(1-drawn);
blue<-blue+(drawn);
しかし、以上の2色があるとき、これは明らかに動作しません:次のように私はそれをやった2色で
。どのように私は3つ以上の色でアプローチする必要がありますか? Wikipediaによれば