# Calculations for the maximization problem of 2/2 > n=c(1:10) > l=c() > for (x in n){l[x] = choose(x,1)*choose(12-x,2)/choose(12,3)} > barplot(l, names.arg=n) > l [1] 0.25000000 0.40909091 0.49090909 0.50909091 0.47727273 0.40909091 0.31818182 [8] 0.21818182 0.12272727 0.04545455 #Calculations for problem 3 on ws-03 > a = 10 > b = 30 > bayes<-c() > plain<-c() > for (x in c(1:20)){bayes[x]<-((x+a)/(a + b +40))} > bayes [1] 0.1375 0.1500 0.1625 0.1750 0.1875 0.2000 0.2125 0.2250 0.2375 0.2500 [11] 0.2625 0.2750 0.2875 0.3000 0.3125 0.3250 0.3375 0.3500 0.3625 0.3750 > for (x in c(1:20)){plain[x]<-(x/40)} > plain [1] 0.025 0.050 0.075 0.100 0.125 0.150 0.175 0.200 0.225 0.250 0.275 0.300 [13] 0.325 0.350 0.375 0.400 0.425 0.450 0.475 0.500 > bayes-plain [1] 0.1125 0.1000 0.0875 0.0750 0.0625 0.0500 0.0375 0.0250 0.0125 [10] 0.0000 -0.0125 -0.0250 -0.0375 -0.0500 -0.0625 -0.0750 -0.0875 -0.1000 [19] -0.1125 -0.1250 > m<-matrix(c(bayes,plain), ncol=20, nrow=2, byrow=TRUE) > barplot(m2, main="Comparison of Bayesian and naive estimation", xlab="x", col=c("orange", "thistle"), names.arg=c(1:20), beside=TRUE)