Solution to HW set 7. ====================== (a) > cathed = read.table(file="cathed.txt") ## after editing in word-processed file names(cathed) = c("Town","Style","Height","Length") ### 25 x 4: first col is factor of town names cathed2 = cathed[order(cathed$Length),] > plot(cathed2[,4], cathed2[,3], type="n", xlab="Length (feet)", ylab="Height (feet)", main= "English Cathedral Heights vs Lengths, by Style") points(cathed2[cathed2[,2]==0,4],cathed2[cathed2[,2]==0,3], pch=5, type="b") points(cathed2[cathed2[,2]==1,4],cathed2[cathed2[,2]==1,3], pch=18, type="b") legend(locator(), legend=c("Romanesque","Gothic"), pch=c(5,18), lty=c(3,1)) (b) > xtmp = rgamma(1600, shape=3.5) round(quantile(xtmp, probs=c(.9,.99,.996, .999)),2) 90% 99% 99.6% 99.9% 6.22 9.69 10.83 11.56 #### choose max = 12, only one obs is larger: replace it my 12 hist(pmin(xtmp,12), breaks=seq(0,12,by=12/40), prob=T, xlim=c(0,12), xlab="Gamma Variates", ylab="Scaled relative frequency", main=paste("Scaled Histogram of Gamma Variates","\n", "with overlaid Gamma(3.5,1) density")) curve(dgamma(x,3.5), add=T, lty=3)