Day 8 - More on density-preserving abstraction

This example in R shows how to combine histogram merging with transformation.
data(islands)
bhist(islands,10)
bhist.merge(islands,10)
x <- -1/sqrt(islands)
bhist(x,10)
bhist.merge(x,10,4)

Confidence intervals can be checked by making simulations:

x <- rnorm(1e5)
m <- 0
se <- 1
low <- x - se
high <- x + se
sum((lowm))/length(x)
The answer is 68% as required. Now for the binomial case:
n <- 100
p <- 0.3
nx <- rbinom(1e5,n,p)
q <- (nx+1)/(n+2)
se <- sqrt(q*(1-q)/n)*exp(-1/6/nx)
low <- q - se
high <- q + se
sum((lowp))/length(nx)
The answer is slightly less than 68%, because the sampling distribution is binomial, not normal.


Tom Minka
Last modified: Thu Sep 13 12:33:06 Eastern Daylight Time 2001