Rによるデータの解析方法 チョウ　アナン(page47-61) dbinom(59000,1000000,0.05885575) dbinom(1,size=1000000,prob=0.0000082) dbinom(1,1000000,0.0000082) dbinom(0,1000000,0.0000082)+dbinom(1,1000000,0.0000082) sum(dbinom(0:1,1000000,0.0000082)) pbinom(1,1000000,0.0000082) 1-pbinom(381,1000000,0.0000082) n=1000 p=0.05885575 frequencies=seq(25,95,by=1) probabilities=dbinom(frequencies,n,p) plot(frequencies,probabilities,type="h",xlab="frequencies",ylab="probability of frequency") s=500 n=1000000 p=0.0000082 x=xtabs(~rbinom(s,n,p))/s x plot(as.numeric(names(x)),x,type="h",xlim=c(0,30),xlab="frequency",ylab="sample probability of frequency") pbinom(4,size=10,prob=0.5) qbinom(0.3769531,size=10,prob=0.5) havelaar\$Frequency n=1000 p=mean(havelaar\$Frequency/n) qnts=seq(0.005,0.995,by=0.01) plot(qbinom(qnts,n,p),quantile(havelaar\$Frequency,qnts),xlab=paste("quantiles of (",n, ",",round(p,4), ")-binomial",sep=""),ylab="frequencies") havelaar.tab=xtab(~havelaar\$Frequency) havelaar.tab havelaar.probs=xtabs(~havelaar\$Frequency)/nrow(havelaar) round(havelaar.probs,3) sum(havelaar.probs) plot(as.numeric(names(havelaar.probs)),havelaar.probs,xlim=c(0,40),type="h",xlab="counts",ylab="relative frequency")+mtext("observed",3,1) n=1000 p=mean(havelaar\$Frequency/n) p counts=0:40 plot(counts,dbinom(counts,n,p),type="h",xlab="counts",ylab="probability")+mtext("binomial(1000,0.013)",3,1) lambda=n*p plot(counts,dpois(counts,lambda),type="h",xlab="counts",ylab="probability")+mtext("Poisson(13.4)",3,1) sum(dpois(0:80,100)) ppois(80,100)