##### script for slidedeck c9 ##### ##### Slide deck for Gaussian (Normal) distribution ##### ### Preamble ito1 = "#FAFAFF" ## background ito2 = "#00AAE4" ## selected ##### ### Standard Normal distributions (Z) # outline xx = seq(-4,4, length=1e4) yy = dnorm(xx) par(yaxt="n",yaxs="i") par(family="serif",las=1) par(mar=c(3,0,0,0)+0.75) par(font.lab=2,cex.lab=1.1) plot.new() plot.window( xlim=c(-3.2,3.2), ylim=c(0,0.4)) lines(xx,yy, lwd=4) axis(1) title(xlab="Z", line=2.5) # mu showing par(yaxt="n",yaxs="i") par(family="serif",las=1) par(mar=c(3,0,0,0)+0.75) par(font.lab=2,cex.lab=1.1) plot.new() plot.window( xlim=c(-3.2,3.2), ylim=c(0,0.4)) segments(0,0, 0,dnorm(0), col="tan", lwd=4) lines(xx,yy, lwd=4) axis(1) title(xlab="Z", line=2.5) # sd showing par(yaxt="n",yaxs="i") par(family="serif",las=1) par(mar=c(3,0,0,0)+0.75) par(font.lab=2,cex.lab=1.1) plot.new() plot.window( xlim=c(-3.2,3.2), ylim=c(0,0.4)) x1 = seq(-1,1,length=1e4) y1 = dnorm(x1) polygon(x=c(x1,rev(x1)), y=c(y1,rep(0,length(y1))), col=rgb(0.5,0.0,0.9, 0.20), border=NA ) x2 = seq(-2,2,length=1e4) y2 = dnorm(x2) polygon(x=c(x2,rev(x2)), y=c(y2,rep(0,length(y2))), col=rgb(0.5,0.0,0.9, 0.20), border=NA ) x3 = seq(-3,3,length=1e4) y3 = dnorm(x3) polygon(x=c(x3,rev(x3)), y=c(y3,rep(0,length(y3))), col=rgb(0.5,0.0,0.9, 0.20), border=NA ) x4 = seq(-4,4,length=1e4) y4 = dnorm(x4) polygon(x=c(x4,rev(x4)), y=c(y4,rep(0,length(y4))), col=rgb(0.5,0.0,0.9, 0.20), border=NA ) segments(0,0, 0,dnorm(0), col="white", lwd=3) lines(xx,yy, lwd=2) axis(1) title(xlab="Z", line=2.5) ##### ### Example 1: IQ, < par(yaxt="n",yaxs="i") par(family="serif",las=1) par(mar=c(3,0,0,0)+0.75) par(font.lab=2,cex.lab=1.1) plot.new() plot.window( xlim=c(0,200), ylim=c(0,0.03)) xx = seq(0,200,length=1e4) yy = dnorm(xx,m=100,s=15) x1 = seq(0,90,length=1e4) y1 = dnorm(x1,m=100,s=15) polygon(x=c(x1,rev(x1)), y=c(y1,rep(0,length(y1))), col=rgb(0.5,0.0,0.9, 0.50), border=NA ) segments( 90,0, 90, dnorm(90,100,15), col="purple4", lwd=2 ) lines(xx,yy, lwd=3) axis(1) axis(1, at=90) title(xlab="IQ", line=2.5) # Calculation pnorm(90, m=100,s=15) ##### ### Example 2: IQ, between par(yaxt="n",yaxs="i") par(family="serif",las=1) par(mar=c(3,0,0,0)+0.75) par(font.lab=2,cex.lab=1.1) plot.new() plot.window( xlim=c(0,200), ylim=c(0,0.03)) q2 = qnorm(0.33, m=100,s=15) xx = seq(0,200,length=1e4) yy = dnorm(xx,m=100,s=15) x1 = seq(87,122,length=1e4) y1 = dnorm(x1,m=100,s=15) polygon(x=c(x1,rev(x1)), y=c(y1,rep(0,length(y1))), col=rgb(0.5,0.0,0.9, 0.50), border=NA ) lines(xx,yy, lwd=3) vtr= 87; segments( vtr,0, vtr, dnorm(vtr,100,15), col="purple4", lwd=2 ) vtr=122; segments( vtr,0, vtr, dnorm(vtr,100,15), col="purple4", lwd=2 ) axis(1) axis(1, at=c(87,122)) title(xlab="IQ", line=2.5) # Calculation pnorm(122, m=100,s=15) - pnorm(87, m=100,s=15) ##### ### Example 3: IQ, > par(yaxt="n",yaxs="i") par(family="serif",las=1) par(mar=c(3,0,0,0)+0.75) par(font.lab=2,cex.lab=1.1) plot.new() plot.window( xlim=c(0,200), ylim=c(0,0.03)) xx = seq(0,200,length=1e4) yy = dnorm(xx,m=100,s=15) x1 = seq(90,200,length=1e4) y1 = dnorm(x1,m=100,s=15) polygon(x=c(x1,rev(x1)), y=c(y1,rep(0,length(y1))), col=rgb(0.5,0.0,0.9, 0.50), border=NA ) #segments(x1,0, x1,y1, col=rgb(0.5,0,0.9,0.05)) lines(xx,yy, lwd=3) vtr=90; segments( vtr,0, vtr, dnorm(vtr,100,15), col="purple4", lwd=2 ) axis(1) axis(1, at=90) title(xlab="IQ", line=2.5) # Calculation 1 - pnorm(90, m=100,s=15) ##### ### Example 4: IQ, Quantile par(yaxt="n",yaxs="i") par(family="serif",las=1) par(mar=c(3,0,0,0)+0.75) par(font.lab=2,cex.lab=1.1) plot.new() plot.window( xlim=c(0,200), ylim=c(0,0.03)) q2 = qnorm(0.33, m=100,s=15) xx = seq(0,200,length=1e4) yy = dnorm(xx,m=100,s=15) x1 = seq(0,q2,length=1e4) y1 = dnorm(x1,m=100,s=15) polygon(x=c(x1,rev(x1)), y=c(y1,rep(0,length(y1))), col=rgb(0.5,0.0,0.9, 0.50), border=NA ) lines(xx,yy, lwd=3) segments( q2,0, q2, dnorm(q2,100,15), col="purple4", lwd=2 ) axis(1) axis(1, at=q2, label=expression(x[0.3]), line=-0.5) title(xlab="IQ", line=2.5) # Calculation qnorm(0.30, m=100,s=15) ##### End of File