##### script for slidedeck c4 ##### ##### The Hypergeometric Distribution ##### ### Preamble # Two colors ito1 = "#E1EBEE" ## background ito2 = "#00AAE4" ## selected ##### ### Example: Spades A xx = seq(0,4) yy = dhyper(xx, m=13, n=39, k=4) par(bg="transparent") par(xpd=NA) par(xaxs="i", yaxs="i") par(family="serif",las=1) par(mar=c(3.5,4,0,0)+0.5) par(font.lab=2, cex.lab=1.1) plot.new() plot.window( xlim=c(-0.5,4.5), ylim=c(0,0.5)) yyVals = 0:5/10 segments(-0.5,yyVals,9,yyVals, lty=3, col="grey") segments(-0.5,0,15,0) axis(1, at=0:11) axis(2, at= yyVals) title(xlab="Number of Spades Drawn", line=2.50) title(ylab="Probability", line=3.25) segments(xx,0,xx,yy) points(xx,yy, pch=21, bg=ito2) ### Calculation # 1 dhyper(1, m=13, n=39, k=4) # 2 phyper(3, m=13, n=39, k=4) ##### ### Example: STAT 200 xx = seq(0,41) yy = dhyper(xx, m=356, n=978, k=41) par(bg="transparent") par(xpd=NA) par(xaxs="i", yaxs="i") par(family="serif",las=1) par(mar=c(3.5,4,0,0)+0.5) par(font.lab=2, cex.lab=1.1) plot.new() plot.window( xlim=c(-0.5,41.5), ylim=c(0,0.20)) yyVals = 0:4*0.05 segments(-0.5,yyVals,42,yyVals, lty=3, col="grey") segments(-0.5,0,15,0) axis(1, at=seq(0,46,4)) axis(2, at= yyVals) title(xlab="Number of Third-Years", line=2.50) title(ylab="Probability", line=3.25) segments(xx,0,xx,yy) points(xx,yy, pch=21, bg=ito2) ### Calculations 1 - phyper(18, m=356, n=978, k=41) ##### ### Example: MATH 121 xx = seq(0,30) yy = dhyper(xx, m=278, n=1056, k=30) par(bg="transparent") par(xpd=NA) par(xaxs="i", yaxs="i") par(family="serif",las=1) par(mar=c(3.5,4,0,0)+0.5) par(font.lab=2, cex.lab=1.1) plot.new() plot.window( xlim=c(-0.5,30.5), ylim=c(0,0.20)) yyVals = 0:4*0.05 segments(-0.5,yyVals,31,yyVals, lty=3, col="grey") segments(-0.5,0,15,0) axis(1, at=seq(0,30,2)) axis(2, at= yyVals) title(xlab="Number of Fourth-Years", line=2.50) title(ylab="Probability", line=3.25) segments(xx,0,xx,yy) points(xx,yy, pch=21, bg=ito2) ### Calculations phyper(3, m=278, n=1056, k=30) ##### ### Example: The Unemployed xx = seq(0,5) yy = dhyper(xx, m=2, n=9, k=5) par(bg="transparent") par(xpd=NA) par(xaxs="i", yaxs="i") par(family="serif",las=1) par(mar=c(3.5,4,0,0)+0.5) par(font.lab=2, cex.lab=1.1) plot.new() plot.window( xlim=c(-0.5,5.5), ylim=c(0,0.60)) yyVals = 0:6*0.10 segments(-0.5,yyVals,5,yyVals, lty=3, col="grey") segments(-0.5,0,15,0) axis(1, at=seq(0,5,1)) axis(2, at= yyVals) title(xlab="Number of Unemployed on Committee", line=2.50) title(ylab="Probability", line=3.25) segments(xx,0,xx,yy) points(xx,yy, pch=21, bg=ito2) ### Calculations 4 * 2/11 1 - phyper(2, m=2, n=9, k=5) dhyper(0, m=2, n=9, k=5) qhyper( c(0.25,0.75), m=2, n=9, k=5) ##### End of File