### pdfs, cdfs, quantiles, ecdf # pdf of the standard normal z <- seq(-4,4,0.01) # seq() produces a sequence of numbers y <- dnorm(z) plot(z,y,type="l",main="pdf of the standard normal") # cdf of the standard normal p <- pnorm(z) plot(z,p,type="l",main="cdf of the standard normal") # quantiles of the standard normal qnorm(0.50) # median qnorm(0.025) # the 2.5% value qnorm(0.975) # the 97.5% value # make the same plots for the Normal(mu = 65, sigma=3) distribution. # make the same plots for the exponential distribution. # For the voter participation by state in the 1844 Presidential Election plot its ecdf part <- c(67.5,65.6,65.7,59.3,39.8, 76.1,73.6,81.6,75.5,85.0, 80.3,54.5,79.1,94.0,80.3, 89.6,44.7,82.7,89.7,83.6, 84.9,76.3,74.7,68.8,79.3) hist(part) z <- (part - mean(part))/stdev(part) cdf.compare(z, dist="normal") quantile(part, 0.50)