# The exact upper tail binomial probability for Example 1.1.2 # Note that pbinom is the CDF for the binomial distribution > 1 -pbinom(25, 40, .5) [1] 0.04034523 # Normal approximation with continuity correction > 1 -pnorm(1.74,0,1) [1] 0.04092951 # Normal approximation without continuity correction > 1 -pnorm(1.90,0,1) [1] 0.02871656 # ------------------------------------------------------------------ tab111 <- c(72.1, 72.8, 72.9, 73.3, 73.3, 73.3, 73.9, 74.0, 74.2, 74.2, 74.3, 74.6, 74.7, 75.0, 75.1, 75.1, 75.2, 75.3, 75.3, 75.3, 75.4, 76.1, 76.5, 76.5, 76.6, 76.9, 77.1, 77.2, 77.4, 77.4, 77.7, 78.0, 78.3, 78.6, 78.8, 78.9, 79.7, 80.3, 80.5, 81.0) # wilcox.test computes a nonparametric confidence interval for the median, # but it not exactly the same as what we get, it is slightly shorter in length wilcox.test(tab111,conf.int=TRUE,conf.level=0.95,exact=TRUE) # ------------------------------------------------------------------- # one way to plot the empirical cdf tab121 <- c(7, 11, 15, 16, 20, 22, 24, 25, 29, 33, 34, 37, 41, 42, 49, 57, 66, 71, 84, 90) plot(ecdf(tab121),main="ECDF from Table 1.2.1")