diff --git a/ch5/2.Rmd b/ch5/2.Rmd index 345f714..d067a65 100644 --- a/ch5/2.Rmd +++ b/ch5/2.Rmd @@ -27,7 +27,11 @@ pr = function(n) return(1 - (1 - 1/n)^n) x = 1:100000 plot(x, pr(x)) ``` -The plot quickly reaches an asymptote of about 63.2%. +The plot quickly reaches an asymptote of about 63.2%. This is what we should expect, because a standard result from calculus tells us that $\lim_{n \to \infty} (1 + \frac{x}{n})^n = e^{x}$ for any $x \in \mathbb{R}$, which means that + +$$ +1 - \lim_{n \to \infty} \left( 1 - \frac{1}{n}\right)^n = 1 - e^{-1} \approx 0.632 +$$ ### h ```{r} diff --git a/ch5/2.html b/ch5/2.html index b0f66d5..9752ca3 100644 --- a/ch5/2.html +++ b/ch5/2.html @@ -1,229 +1,390 @@ - - -
- -\( 1 - 1/n \)
-\( 1 - 1/n \)
-In bootstrap, we sample with replacement so each observation in the bootstrap -sample has the same 1/n (independent) chance of equaling the jth observation. -Applying the product rule for a total of n observations gives us \( (1 - 1/n)^n \).
-\( Pr(in) = 1 - Pr(out) = 1 - (1 - 1/5)^5 = 1 - (4/5)^5 = 67.2\% \)
+\(1 - 1/n\)
+\(1 - 1/n\)
+In bootstrap, we sample with replacement so each observation in the bootstrap sample has the same 1/n (independent) chance of equaling the jth observation. Applying the product rule for a total of n observations gives us \((1 - 1/n)^n\).
+\(Pr(in) = 1 - Pr(out) = 1 - (1 - 1/5)^5 = 1 - (4/5)^5 = 67.2\%\)
+\(Pr(in) = 1 - Pr(out) = 1 - (1 - 1/100)^{10} = 1 - (99/100)^{100} = 63.4\%\)
+\(1 - (1 - 1/10000)^{10000} = 63.2\%\)
+pr = function(n) return(1 - (1 - 1/n)^n)
+x = 1:100000
+plot(x, pr(x))
+The plot quickly reaches an asymptote of about 63.2%. This is what we should expect, because a standard result from calculus tells us that \(\lim_{n \to \infty} (1 + \frac{x}{n})^n = e^{x}\) for any \(x \in \mathbb{R}\), which means that
+\[ +1 - \lim_{n \to \infty} \left( 1 - \frac{1}{n}\right)^n = 1 - e^{-1} \approx 0.632 +\]
+set.seed(1)
+store = rep(NA, 1e4)
+for (i in 1:1e4) {
+ store[i] = sum(sample(1:100, rep=T) == 4) > 0
+}
+mean(store)
+## [1] 0.6408
+The numerical results show an approximate mean probability of 64.1%, close to our theoretically derived result.
+\( Pr(in) = 1 - Pr(out) = 1 - (1 - 1/100)^{10} = 1 - (99/100)^{100} = 63.4\% \)
-\( 1 - (1 - 1/10000)^{10000} = 63.2\% \)
-pr = function(n) return(1 - (1 - 1/n)^n)
-x = 1:1e+05
-plot(x, pr(x))
-
+
-
+
+
+
-