Added an exercise

This commit is contained in:
2026-11-05 09:40:17 -05:00
parent ac71393bdd
commit 9395bdce9e
+226 -153
View File
@@ -2,28 +2,37 @@
<title>Confidence Intervals</title>
<p>
When estimating the value of some parameter, the maximum likelihood estimation provides the single estimate with highest possible likelihood.
But we might prefer to have a range of values, with some quantitative measure of how certain we are that the true parameter value could be in the range.
When estimating the value of some parameter, the maximum likelihood
estimation provides the single estimate with highest possible likelihood.
But we might prefer to have a range of values, with some quantitative
measure of how certain we are that the true parameter value could be in the
range.
</p>
<p>
Suppose some measurement has a mean <m>\mu</m> and variance <m>\sigma^2</m> across the entire population.
Independent measurements <m>X_1, X_2, \dotsc, X_n</m> and calculate the sample mean
Suppose some measurement has a mean <m>\mu</m> and variance <m>\sigma^2</m>
across the entire population.
Independent measurements <m>X_1, X_2, \dotsc, X_n</m> and calculate the
sample mean
<md>
<mrow> A_n = \frac{X_1 + \dotsb + X_n}{n}. </mrow>
</md>
Then, according to <xref ref="thm-CLT"/>, <m>A_n \approx \Norm\left(\mu, \frac{\sigma^2}{n}\right)</m> as long as we take a sufficient number of measurements.
Then, according to <xref ref="thm-CLT"/>,
<m>A_n \approx \Norm\left(\mu, \frac{\sigma^2}{n}\right)</m> as long as we
take a sufficient number of measurements.
However, we don't have access to the true values of <m>\mu, \sigma^2</m>.
</p>
<p>
We can make an estimate <m>s^2</m> of <m>\sigma^2</m> from the collected data, so we know how spread out the normal distribution should be.
We can make an estimate <m>s^2</m> of <m>\sigma^2</m> from the collected
data, so we know how spread out the normal distribution should be.
</p>
<definition xml:id="def-sample-variance">
<statement>
<p>
Let <m>X_1, X_2, \dotsc, X_n</m> be independent samples taken from a population.
Let <m>X_1, X_2, \dotsc, X_n</m> be independent samples taken from a
population.
Let <m>A_n = \frac{X_1 + \dotsb + X_n}{n}</m> be the sample mean.
The <term>sample variance</term> is:
<md>
@@ -39,26 +48,35 @@
</definition>
<p>
Note that <m>s^2</m> is an estimate of the variance of each individual measurement <m>X_i</m> taken from the population.
Therefore, <m>\frac{s^2}{n}</m> is an estimate of the variance of the mean <m>A_n</m>.
Hence "standard error of the mean" is an estimate of the standard deviation of the mean.
Note that <m>s^2</m> is an estimate of the variance of each individual
measurement <m>X_i</m> taken from the population.
Therefore, <m>\frac{s^2}{n}</m> is an estimate of the variance of the mean
<m>A_n</m>.
Hence "standard error of the mean" is an estimate of the standard deviation
of the mean.
</p>
<p>
Next, we want to pick a distance <m>c</m> so that our measured sample mean <m>A_n</m> is within <m>c</m> of the true population mean <m>\mu</m> with a high probability.
We can pick some value <m>\alpha \in (0, 1)</m>, and let <m>c_{\alpha} = \Phi^{-1}\left(1 - \frac{\alpha}{2}\right)</m>.
Next, we want to pick a distance <m>c</m> so that our measured sample mean
<m>A_n</m> is within <m>c</m> of the true population mean <m>\mu</m> with a
high probability.
We can pick some value <m>\alpha \in (0, 1)</m>, and let
<m>c_{\alpha} = \Phi^{-1}\left(1 - \frac{\alpha}{2}\right)</m>.
Then the interval:
<md>
<mrow> \left[A_n - c_{\alpha} \left(\frac{s}{\sqrt{n}}\right), A_n + c_{\alpha} \left(\frac{s}{\sqrt{n}}\right)\right] </mrow>
</md>
is called a <term>confidence interval</term> with confidence level <m>1 - \alpha</m>.
is called a <term>confidence interval</term> with confidence level
<m>1 - \alpha</m>.
</p>
<!-- TODO: explanation of c_{\alpha} -->
<theorem xml:id="thm-CI">
<statement>
<p>
Let <m>X_1, X_2, \dotsc, X_n</m> be independent samples taken from a population.
Suppose <m>A_n</m> is the sample mean and <m>s^2</m> the sample variance.
Let <m>X_1, X_2, \dotsc, X_n</m> be independent samples taken from a
population.
Suppose <m>A_n</m> is the sample mean and <m>s^2</m> the sample
variance.
Then the 95% confidence limits are:
<md>
<mrow> \mu_{\ell} \amp = A_n - 1.96 \left(\frac{s}{\sqrt{n}}\right) </mrow>
@@ -71,10 +89,13 @@
<example>
<statement>
<p>
Suppose measurements are taken of the heights of several plants in a garden plot.
Suppose measurements are taken of the heights of several plants in a
garden plot.
The measurements are given below.
(Note: for the sake of a managable calculation, only five measurements are given.
However, for <xref ref="thm-CLT"/> to apply, the number of measurements would need to be greater.)
(Note: for the sake of a managable calculation, only five measurements
are given.
However, for <xref ref="thm-CLT"/> to apply, the number of measurements
would need to be greater.)
</p>
<table>
@@ -140,10 +161,16 @@
</example>
<p>
If the individual measurements <m>X_1, \dotsc, X_n</m> are indicator random variables, then the mean <m>A_n</m> represents the proportion which take on the value 1.
For example, if the <m>X_i</m>'s indicate heads on coin flips, then <m>A_n</m> represents the proportion which come up heads.
In this setting, we have a nice shortcut formula (<xref ref="example-binomial-variance"/>) for the variance of <m>S_n = X_1 + \dotsc + X_n</m>.
We can make use of this formula to get the variance of <m>A_n</m> without going through the sample variance calculation above:
If the individual measurements <m>X_1, \dotsc, X_n</m> are indicator random
variables, then the mean <m>A_n</m> represents the proportion which take on
the value 1.
For example, if the <m>X_i</m>'s indicate heads on coin flips, then
<m>A_n</m> represents the proportion which come up heads.
In this setting, we have a nice shortcut formula
(<xref ref="example-binomial-variance"/>) for the variance of
<m>S_n = X_1 + \dotsc + X_n</m>.
We can make use of this formula to get the variance of <m>A_n</m> without
going through the sample variance calculation above:
<md>
<mrow> \Var(S_n) \amp = np(1 - p) </mrow>
<mrow> \Var(A_n) \amp = \Var\left(\frac{S_n}{n}\right) </mrow>
@@ -151,14 +178,16 @@
<mrow> \amp = \frac{1}{n^2} (np(1 - p)) </mrow>
<mrow> \amp = \frac{p(1 - p)}{n}. </mrow>
</md>
Since we won't have access to the true value of <m>p</m>, we can use the maximum likelihood estimate <m>\widehat{p}</m>.
Since we won't have access to the true value of <m>p</m>, we can use the
maximum likelihood estimate <m>\widehat{p}</m>.
</p>
<example>
<statement>
<p>
Suppose in a sample of 100 people, 40 have a particular trait.
The maximum likelihood estimate for the probability <m>p</m> of a random person having the trait is <m>\widehat{p} = \frac{40}{100} = 0.4</m>.
The maximum likelihood estimate for the probability <m>p</m> of a random
person having the trait is <m>\widehat{p} = \frac{40}{100} = 0.4</m>.
So the standard error will be:
<md>
<mrow> \sqrt{\frac{(0.4)(1 - 0.4)}{100}} = \sqrt{\frac{0.24}{100}} \approx 0.049. </mrow>
@@ -173,162 +202,206 @@
</example>
<exercises xml:id="exercises-Confidence-Intervals">
<exercise>
<statement>
<p>
Suppose we flip a coin 100 times and count 60 heads.
Let <m>p</m> be the (unknown) probability that the coin comes up heads on a flip.
Give an approximate 95% confidence interval for the value of <m>p</m>.
</p>
</statement>
<answer>
<p>
<m>[0.504, 0.696]</m>.
</p>
</answer>
</exercise>
<exercise>
<introduction>
<p>
Suppose in a sample of 100 people, 12 are left-handed.
</p>
</introduction>
<task>
<exercise>
<statement>
<p>
Give a 95% confidence interval for the proportion <m>p</m> of left-handed people.
Suppose we flip a coin 100 times and count 60 heads.
Let <m>p</m> be the (unknown) probability that the coin comes up heads
on a flip.
Give an approximate 95% confidence interval for the value of <m>p</m>.
</p>
</statement>
<answer>
<p>
<m>[0.056, 0.184]</m>.
<m>[0.504, 0.696]</m>.
</p>
</answer>
</task>
</exercise>
<exercise>
<introduction>
<p>
Suppose in a sample of 100 people, 12 are left-handed.
</p>
</introduction>
<task>
<task>
<statement>
<p>
Give a 95% confidence interval for the proportion <m>p</m> of
left-handed people.
</p>
</statement>
<answer>
<p>
<m>[0.056, 0.184]</m>.
</p>
</answer>
</task>
<task>
<statement>
<p>
Give a 90% confidence interval.
</p>
</statement>
<answer>
<p>
<m>[0.066, 0.174]</m>.
</p>
</answer>
</task>
</exercise>
<exercise>
<introduction>
<p>
Suppose a sample of measurements are taken, and the sample is found to
have a mean of <m>20.2</m> with a standard error of <m>4.3</m>.
</p>
</introduction>
<task>
<statement>
<p>
Find the 95% confidence limits.
</p>
</statement>
</task>
<task>
<statement>
<p>
Find the 92% confidence limits.
</p>
</statement>
</task>
<task>
<statement>
<p>
Find the 97% confidence limits.
</p>
</statement>
</task>
<task>
<statement>
<p>
Find the 99% confidence limits.
</p>
</statement>
</task>
</exercise>
<exercise>
<statement>
<p>
Give a 90% confidence interval.
The weights of five mice are measured and recorded below.
Give a 95% confidence interval for the sample mean weight of mice.
(Pretend 5 measurements is large enough for the CLT to apply.)
</p>
<table>
<title/>
<tabular halign="center">
<row header="yes" bottom="minor">
<cell>mouse <m>i</m></cell>
<cell>weight <m>W_i</m> (g)</cell>
</row>
<row>
<cell>1</cell>
<cell>26</cell>
</row>
<row>
<cell>2</cell>
<cell>32</cell>
</row>
<row>
<cell>3</cell>
<cell>33</cell>
</row>
<row>
<cell>4</cell>
<cell>20</cell>
</row>
<row>
<cell>5</cell>
<cell>29</cell>
</row>
</tabular>
</table>
</statement>
<answer>
<p>
<m>[0.066, 0.174]</m>.
<!-- avg weight = 28 --> <!-- sum of squares = 4030 -->
<!-- s^2 = 27.5 --> <!-- \sqrt{s^2/n} \approx 2.35 -->
<m>[23.39, 32.61]</m>.
</p>
</answer>
</task>
</exercise>
</exercise>
<exercise>
<statement>
<p>
The weights of five mice are measured and recorded below.
Give a 95% confidence interval for the sample mean weight of mice.
(Pretend 5 measurements is large enough for the CLT to apply.)
</p>
<exercise>
<statement>
<p>
The heights of five plants are measured and recorded below.
Give a 95% confidence interval around the sample mean for the heights
of the plants.
(Pretend 5 measurements is large enough for the CLT to apply.)
</p>
<table>
<title></title>
<table>
<title/>
<tabular halign="center">
<row header="yes" bottom="minor">
<cell>plant <m>i</m></cell>
<cell>height <m>H_i</m> (in)</cell>
</row>
<tabular halign="center">
<row header="yes" bottom="minor">
<cell>mouse <m>i</m></cell>
<cell>weight <m>W_i</m> (g)</cell>
</row>
<row>
<cell>1</cell>
<cell>15</cell>
</row>
<row>
<cell>1</cell>
<cell>26</cell>
</row>
<row>
<cell>2</cell>
<cell>14</cell>
</row>
<row>
<cell>2</cell>
<cell>32</cell>
</row>
<row>
<cell>3</cell>
<cell>18</cell>
</row>
<row>
<cell>3</cell>
<cell>33</cell>
</row>
<row>
<cell>4</cell>
<cell>21</cell>
</row>
<row>
<cell>4</cell>
<cell>20</cell>
</row>
<row>
<cell>5</cell>
<cell>17</cell>
</row>
</tabular>
</table>
</statement>
<row>
<cell>5</cell>
<cell>29</cell>
</row>
</tabular>
</table>
</statement>
<answer>
<p>
<!-- avg weight = 28 --> <!-- sum of squares = 4030 --> <!-- s^2 = 27.5 --> <!-- \sqrt{s^2/n} \approx 2.35 --> <m>[23.39, 32.61]</m>.
</p>
</answer>
</exercise>
<exercise>
<statement>
<p>
The heights of five plants are measured and recorded below.
Give a 95% confidence interval around the sample mean for the heights of the plants.
(Pretend 5 measurements is large enough for the CLT to apply.)
</p>
<table>
<title></title>
<tabular halign="center">
<row header="yes" bottom="minor">
<cell>plant <m>i</m></cell>
<cell>height <m>H_i</m> (in)</cell>
</row>
<row>
<cell>1</cell>
<cell>15</cell>
</row>
<row>
<cell>2</cell>
<cell>14</cell>
</row>
<row>
<cell>3</cell>
<cell>18</cell>
</row>
<row>
<cell>4</cell>
<cell>21</cell>
</row>
<row>
<cell>5</cell>
<cell>17</cell>
</row>
</tabular>
</table>
</statement>
<answer>
<p>
<!-- avg weight = 17 --> <!-- sum of squares = 1475 --> <!-- s^2 = 7.5 --> <!-- \sqrt{s^2/n} \approx 1.22 --> <m>[14.61, 19.39]</m>.
</p>
</answer>
</exercise>
<answer>
<p>
<!-- avg weight = 17 --> <!-- sum of squares = 1475 -->
<!-- s^2 = 7.5 --> <!-- \sqrt{s^2/n} \approx 1.22 -->
<m>[14.61, 19.39]</m>.
</p>
</answer>
</exercise>
</exercises>
</section>