new.urn <- function(n.balls=2,black.proportion=0.5) { return(c('black'=n.balls*black.proportion, 'white'=n.balls*(1-black.proportion))) } proportion <- function(urn) { return(urn['black']/sum(urn)) } draw.ball <- function(urn) { prob.black <- proportion(urn) drawn.ball <- c('white','black')[1*(runif(1)=observed.test.statistic) / precision ci <- p.value + c(-1,1)*qnorm(1-0.05/2)*sqrt(p.value*(1-p.value)/precision) cat("p-value is ",p.value,", with a 95% confidence interval of (",ci[1],",",ci[2],")\n",sep="") #table(draws) hist(draws) # What is the rejection region? # How could you do a power calculation?