1. p-hacking 2. map01 <- function(x) { m <- min(x); M <- max(x) newx <- (x - m) / (M - m) tmp <- list(m=m,M=M,newx=newx) class(tmp) <- 'm01' } newNile <- map01(Nile) # Nile is a built-in dataset in R print(sd(newNile$newx)) # about 0.185 3. We will need to predict new cases in the future, and must transform them in the same way. Hence we need to retain m and M. 4. lp <- function(x,p) { if (p == Inf) return(max(x)) (sum(x^p))^(1/p) } # LakeHuron is another built-in dataset print(lp(LakeHuron,2)) # about 5731.9 print(lp(LakeHuron,1)) # 56742.4 print(lp(LakeHuron,Inf)) # 581.86 5. We wish to do dimension reduction. ZIP codes are arranged so that the first two digits do give us some regional information, e.g. 94 for all the Bay Area.