# Jakaumia Binomijakauma n<- 40; p<- 1/4 x<-29:31 sum(dbinom(x,n,p)) pbinom(31,n,p)-pbinom(28,n,p) # toinen tapa plot(dbinom(x,n,p)) plot(x,dbinom(x,n,p)) =================== # Geometrinen jakauma # R:ssä lasketaan ennen 1. onnistumista sattuvien epäonnistumisten lukumäärää x: 0,1,... # Yritysten määrä on x+1 x<-1:15; p<-0.4 plot(x,dgeom(x-1,p),type="h") par(mfrow=c(2,2)) p<-0.2; plot(x,dgeom(x-1,p),type="h",ylim=c(0,0.8)) p<-0.4; plot(x,dgeom(x-1,p),type="h",ylim=c(0,0.8)) p<-0.6; plot(x,dgeom(x-1,p),type="h",ylim=c(0,0.8)) p<-0.8; plot(x,dgeom(x-1,p),type="h",ylim=c(0,0.8)) # Olkoon Y yritysten määrä # P(Y<= 5), kun p<-0.04 # P(Y<= 5)=P(Y-1=<= 5-1)=P(X=<= 4) p<-0.4 pgeom(4,p) p<-0.2 # P(2<=Y<= 5)=P(1<=x<= 4) x<-1:4 sum(dgeom(x,p)) # P(2<=Y<= 5)=P(1<=x<= 4)=P(0