##### Slidedeck c2 ##### ##### Create graphics for Bernoulli/Binomial ##### ### Preamble # define two colors ito1 = "#E1EBEE" ## background ito2 = "#00AAE4" ## selected ##### ### Bernoulli ## CDF p<0.500 p=0.33 xx = seq(-1,2,length=1e4) yy = pbinom(xx, size=1,prob=p) # par(xpd=NA) par(xaxs="i", yaxs="i") par(family="serif",las=1) par(mar=c(1.5,4,0,0)+0.5) par(font.lab=2, cex.lab=1.1) plot.new() plot.window( xlim=c(-0.25,1.25), ylim=c(0,1.05)) yyVals = 0:5/5 segments(-0.25,yyVals,1.5,yyVals, lty=3, col="grey") axis(1, at=0:3) axis(2, at=yyVals) title(xlab="X", line=0.5) title(ylab="Cumulative Probability", line=3.15) segments(-3,0,0,0, col=ito2, lwd=2) segments(0,1-p,1,1-p, col=ito2, lwd=2) segments(1,1,5,1, col=ito2, lwd=2) points(0,0, pch=21, bg="white", col= ito2, cex=2); points(1,1-p, pch=21, bg="white", col= ito2, cex=2) points(0,1-p,pch=16, col=ito2, lwd=2, cex=2); points(1,1, pch=16, col=ito2, lwd=2, cex=2) ## CDF p=0.500 p=0.50 xx = seq(-1,2,length=1e4) yy = pbinom(xx, size=1,prob=p) par(xpd=NA) par(xaxs="i", yaxs="i") par(family="serif",las=1) par(mar=c(1.5,4,0,0)+0.5) par(font.lab=2, cex.lab=1.1) plot.new() plot.window( xlim=c(-0.25,1.25), ylim=c(0,1.05)) yyVals = 0:5/5 segments(-0.25,yyVals,1.5,yyVals, lty=3, col="grey") axis(1, at=0:3) axis(2, at=yyVals) title(xlab="X", line=0.5) title(ylab="Cumulative Probability", line=3.15) segments(-3,0,0,0, col=ito2, lwd=2) segments(0,1-p,1,1-p, col=ito2, lwd=2) segments(1,1,5,1, col=ito2, lwd=2) points(0,0, pch=21, bg="white", col= ito2, cex=2); points(1,1-p, pch=21, bg="white", col= ito2, cex=2) points(0,1-p,pch=16, col=ito2, lwd=2, cex=2); points(1,1, pch=16, col=ito2, lwd=2, cex=2) ## CDF p>0.500 p=0.66 xx = seq(-1,2,length=1e4) yy = pbinom(xx, size=1,prob=p) par(xpd=NA) par(xaxs="i", yaxs="i") par(family="serif",las=1) par(mar=c(1.5,4,0,0)+0.5) par(font.lab=2, cex.lab=1.1) plot.new() plot.window( xlim=c(-0.25,1.25), ylim=c(0,1.05)) yyVals = 0:5/5 segments(-0.25,yyVals,1.5,yyVals, lty=3, col="grey") axis(1, at=0:3) axis(2, at=yyVals) title(xlab="X", line=0.5) title(ylab="Cumulative Probability", line=3.15) segments(-3,0,0,0, col=ito2, lwd=2) segments(0,1-p,1,1-p, col=ito2, lwd=2) segments(1,1,5,1, col=ito2, lwd=2) points(0,0, pch=21, bg="white", col= ito2, cex=2); points(1,1-p, pch=21, bg="white", col= ito2, cex=2) points(0,1-p,pch=16, col=ito2, lwd=2, cex=2); points(1,1, pch=16, col=ito2, lwd=2, cex=2) ##### ### The Five Examples # Ex 1a dbinom(3, size=10, prob=0.500) # Ex 1b dbinom(7, size=10, prob=0.500) # Ex 1c pbinom(3, size=10, prob=0.500) + (1-pbinom(6, size=10, prob=0.500)) # Ex 2 1 - pbinom(0, size=18721, prob=0.0001) # Ex 3 1 - pbinom(7, size=10, prob=0.500) # Ex 4 1 - pbinom(47, size=50, prob=0.800) # Ex 5 1 - pbinom(11, size=40, prob=0.25) ##### End of File