Here is an example of a nonparametric bootstrap confidence interval -- with some explanation of how it is obtained.
Suppose I have $n = 30$ observations from an unknown distribution and want a 95% confidence interval for the population mean $\mu.$ (Ignore numbers in brackets.)
y
[1] 22.1 25.9 30.3 6.7 18.1 13.6 13.4 40.4 14.9 37.3 16.9 22.1 26.3 24.7 39.6
[16] 27.0 22.5 11.1 10.8 31.4 38.4 22.3 30.4 24.3 26.5 31.7 14.0 13.9 49.2 47.9
mean(y)
[1] 25.12333
I take $\bar Y = 25.12333,$ denoted a.obs in the program below, as a
point estimate of $\mu.$
In order to make a confidence interval (CI), I have to know about the variability
of the population around its mean. If I knew the distribution pf $D = \bar Y = \mu,$
I could find numbers $L$ and $U,$ such that
$P(L \le D = \bar Y - \mu \le U) = 0.95.$ Then I would have $P(\bar Y - U \le \mu \le \bar Y - L) = 0.95$ and a 95% CI for $\mu$ would be of the form $(\bar Y - U, \bar Y - L).$
Not knowing the values $L$ and $U,$ I enter the 'bootstrap world' in order to
get estimates $L^*$ and $U^*$ of these values, respectively. Momentarily, I take the observed $\bar Y$ as
a proxy for the unknown $\mu.$ I take a large number $B$ of "re-samples"
of of the data. Each re-sample is of size $n = 30$ and re-samples are taken with replacement from the original sample.
For each re-sample, I find the mean $\bar Y^*$ and $D^* = \bar Y^* - \bar Y.$
This gives me a $B$ values $D^*.$ I cut 2.5% from the lower and upper ends
of this collection of $D^*$'s to find the required values $L^*$ and $U^*.$
Returning, to the "real world", $\bar Y$ returns to it's original role as the observed mean of the sample, and a 95% nonparametric bootstrap CI for $\mu$ is
of the form $\bar Y - U^*, \bar Y - L^*).$
In the following R program, suffixes .re are used instead of $*$'s to
indicate quantities that result from re-sampling and the observed $\bar Y$ is
called a.obs. The program assumes that the data y are already present.
set.seed(624); B = 10^4; d.re = numeric(B)
a.obs = mean(y); n = length(y)
for (i in 1:B) {
a.re = mean(sample(y, n, repl=T))
d.re[i] = a.re - a.obs }
L.re = quantile(d.re, .025); U.re = quantile(d.re, .975)
c(a.obs - U.re, a.obs - L.re)
97.5% 2.5%
21.14325 28.88333
Thus a 95% nonparametric bootstrap CI for $\mu$ is $(21.1, 28.9).$
Each run of the program gives a slightly different result if you
omit the set.seed statement; retain that statement to replicate
the exact answer above. However, with $B = 10,000$ iterations
differences from one run to another will be small; a second
run with an unknown seed gave the interval $(21.2, 29.0).$
A 95% t confidence interval is $(21.0, 29.2).$ It is based on the
assumption that the data are normal (and contemplates the symmetrical tails of a
normal population). The bootstrap CI assumes that the data are
a random sample from a population with mean $\mu$. It assumes only
that the population is capable of producing the values observed.
Notes: (1) The data y were randomly sampled from a gamma distribution with shape
parameter 5 and mean 25.
(2) This is a 'bias-corrected' bootstrap CI. A version without bias
correction would be to bootstrap a.re and use quantile(a.re, c(.025,.975)) as the CI. Some authors do that and then apply bias correction retroactively, using 2*a.obs - quantile(a.re, c(.025,.975)). (This is equivalent to the program above, but then it's not so easy to explain the role of 2*a.obs.)