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 @@ - - - - -Chapter 5: Exercise 2 + - + + + + + + -hr { - height: 0px; - border-bottom: none; - border-top-width: thin; - border-top-style: dotted; - border-top-color: #999999; + + + -@media print { - * { - background: transparent !important; - color: black !important; - filter:none !important; - -ms-filter: none !important; - } - - body { - font-size:12pt; - max-width:100%; - } - - a, a:visited { - text-decoration: underline; - } - - hr { - visibility: hidden; - page-break-before: always; - } - pre, blockquote { - padding-right: 1em; - page-break-inside: avoid; - } - tr, img { - page-break-inside: avoid; - } + - img { - max-width: 100% !important; - } - @page :left { - margin: 15mm 20mm 15mm 10mm; - } - - @page :right { - margin: 15mm 10mm 15mm 20mm; - } + - p, h2, h3 { - orphans: 3; widows: 3; - } + - h2, h3 { - page-break-after: avoid; - } + - - - - +
- - + - - -

Chapter 5: Exercise 2

-

a

-

\( 1 - 1/n \)

-

b

+ -

\( Pr(in) = 1 - Pr(out) = 1 - (1 - 1/5)^5 = 1 - (4/5)^5 = 67.2\% \)

+
+

Chapter 5: Exercise 2

+
+

a

+

\(1 - 1/n\)

+
+
+

b

+

\(1 - 1/n\)

+
+
+

c

+

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\).

+
+
+

d

+

\(Pr(in) = 1 - Pr(out) = 1 - (1 - 1/5)^5 = 1 - (4/5)^5 = 67.2\%\)

+
+

e

+

\(Pr(in) = 1 - Pr(out) = 1 - (1 - 1/100)^{10} = 1 - (99/100)^{100} = 63.4\%\)

+
+
+

f

+

\(1 - (1 - 1/10000)^{10000} = 63.2\%\)

+
+
+

g

+
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 +\]

+
+
+

h

+
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\% \)

-

f

-

\( 1 - (1 - 1/10000)^{10000} = 63.2\% \)

-

g

+
-
pr = function(n) return(1 - (1 - 1/n)^n)
-x = 1:1e+05
-plot(x, pr(x))
-
+ - + + + -