Latest build deployed.

This commit is contained in:
2026-03-19 08:39:29 -04:00
parent 9b35fe42bf
commit 65cf93d9c0
359 changed files with 646 additions and 121 deletions
+114 -5
View File
@@ -101,15 +101,15 @@ eBookConfig.allow_pairs = false;
eBookConfig.enableScratchAC = false;
eBookConfig.build_info = "";
eBookConfig.python3 = null;
eBookConfig.runestone_version = '7.11.15';
eBookConfig.runestone_version = '7.11.19';
eBookConfig.jobehost = '';
eBookConfig.proxyuri_runs = '';
eBookConfig.proxyuri_files = '';
eBookConfig.enable_chatcodes = false;
</script>
<!--*** Runestone Services ***-->
<script src="_static/prefix-runtime.529fd9398bfbd03e.bundle.js"></script><script src="_static/prefix-723.3e6434f80549315a.bundle.js"></script><script src="_static/prefix-runestone.1d6e4aba17c2c7f2.bundle.js"></script><link rel="stylesheet" type="text/css" href="_static/prefix-723.3bccd435914aa0ff.css">
<link rel="stylesheet" type="text/css" href="_static/prefix-runestone.6ec5960970d8b364.css">
<script src="_static/prefix-runtime.998c9d9ee2a5e7ac.bundle.js"></script><script src="_static/prefix-723.3e6434f80549315a.bundle.js"></script><script src="_static/prefix-runestone.98ef3b0c170cd180.bundle.js"></script><link rel="stylesheet" type="text/css" href="_static/prefix-723.3bccd435914aa0ff.css">
<link rel="stylesheet" type="text/css" href="_static/prefix-runestone.b12a7b3f0773ebcd.css">
<script src="_static/pretext/js/lti_iframe_resizer.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.9/lunr.min.js" integrity="sha512-4xUl/d6D6THrAnXAwGajXkoWaeMNwEKK4iNfq5DotEbLPAfk6FSxSP3ydNxqDgCw1c/0Z1Jg6L8h2j+++9BZmg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><script src="lunr-pretext-search-index.js" async=""></script><script src="_static/pretext/js/pretext_search.js"></script><script src="_static/pretext/js/knowl.js"></script><!--knowl.js code controls Sage Cells within knowls--><script>sagecellEvalName='Evaluate (Sage)';
</script>
</head>
@@ -309,9 +309,118 @@ eBookConfig.enable_chatcodes = false;
<main class="ptx-main"><div id="ptx-content" class="ptx-content"><section class="section" id="sec-Two-Sample-Tests"><h2 class="heading hide-type">
<span class="type">Section</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">5.2</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="title">Two Sample Tests</span>
</h2>
<div class="para" id="sec-Two-Sample-Tests-2">Text of section.<div class="autopermalink" data-description="Paragraph"><a href="#sec-Two-Sample-Tests-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
<div class="para" id="sec-Two-Sample-Tests-2">In the previous section, we compared data collected from a sample against a known or supposed baseline. But the statistics for that baseline would also generally be approximated by collecting data from a sample. Well now consider hypothesis tests that directly involve two samples of data, one called a <dfn class="terminology">control group</dfn> and the other an <dfn class="terminology">experimental group</dfn>.<div class="autopermalink" data-description="Paragraph"><a href="#sec-Two-Sample-Tests-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<section class="exercises" id="exercises-Two-Sample-Tests"><h3 class="heading hide-type">
<article class="example example-like" id="sec-Two-Sample-Tests-3"><h3 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">5.2.1</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h3>
<div class="para" id="sec-Two-Sample-Tests-3-1-1">Suppose a sample of 50 plants have a mean height of 35 cm. A separate sample of 30 plants are taken from another plot which has been using a new fertilizer intended to increase plant growth, and they have a mean height of 36.4 cm. If the height of a plant has a variance of <span class="process-math">\(\sigma^2 = 12 \text{cm}^2\text{,}\)</span> do we have strong enough evidence to reject the null hypothesis that the new fertilizer has no effect on plant height?<div class="autopermalink" data-description="Paragraph"><a href="#sec-Two-Sample-Tests-3-1-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div> <div class="para logical" id="sec-Two-Sample-Tests-3-1-2">
<div class="para">Let <span class="process-math">\(A_1\)</span> be the random variable representing average height of the control group of plants. This sample has size <span class="process-math">\(n_1 = 50\text{,}\)</span> and we measured the average height <span class="process-math">\(\mu_1 = 35\text{.}\)</span> The variance of the average height would be:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-3-1-2-4">
\begin{align*}
\Var(A_1) \amp = \frac{\sigma^2}{n_1} = \frac{12}{50} = 0.24.
\end{align*}
</div>
<div class="para">Similarly, let <span class="process-math">\(A_2\)</span> be the random variable representing average height of the experimental group of plants. This sample has size <span class="process-math">\(n_2 = 30\text{,}\)</span> and we measured the average height <span class="process-math">\(\mu_2 = 36.4\text{.}\)</span> The variance of the average height would be:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-3-1-2-8">
\begin{align*}
\Var(A_2) \amp = \frac{\sigma^2}{n_2} = \frac{12}{30} = 0.4.
\end{align*}
</div>
<div class="para">Let <span class="process-math">\(D = A_2 - A_1\)</span> be the difference between the average heights.</div>
<div class="autopermalink" data-description="Paragraph"><a href="#sec-Two-Sample-Tests-3-1-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div> <div class="para logical" id="sec-Two-Sample-Tests-3-1-3">
<div class="para">According to the null hypothesis, the two plots of plants should behave the same way, so <span class="process-math">\(\E(D) = 0\text{.}\)</span> We measured the value:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-3-1-3-2">
\begin{gather*}
D = A_2 - A_1 = 36.4 - 35 = 1.4
\end{gather*}
</div>
<div class="para">The variance would be:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-3-1-3-3">
\begin{gather*}
\Var(D) = \Var(A_2 - A_1) = \Var(A_2) + \Var(A_1) = 0.24 + 0.4 = 0.64.
\end{gather*}
</div>
<div class="para">So, under the null hypothesis, we will treat <span class="process-math">\(D\)</span> as <span class="process-math">\(\Norm(0, 0.64)\text{.}\)</span> We then perform a 1-tailed test:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-3-1-3-6">
\begin{align*}
\Pr(D \geq 1.4) \amp \approx \Pr\left(Z \geq \frac{1.4 - 0}{\sqrt{0.64}}\right) \\
\amp = 1 - \Phi(1.75) \\
\amp = 1 - 0.9599 \\
\amp = 0.0401 \lt 0.05,
\end{align*}
</div>
<div class="para">so we can reject the null hypothesis.</div>
<div class="autopermalink" data-description="Paragraph"><a href="#sec-Two-Sample-Tests-3-1-3" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="autopermalink" data-description="Example 5.2.1"><a href="#sec-Two-Sample-Tests-3" title="Copy heading and permalink for Example 5.2.1" aria-label="Copy heading and permalink for Example 5.2.1">🔗</a></div></article><div class="para" id="sec-Two-Sample-Tests-4">However, we dont know <span class="process-math">\(\sigma^2\text{,}\)</span> so we should replace it with the sample variance.<div class="autopermalink" data-description="Paragraph"><a href="#sec-Two-Sample-Tests-4" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<article class="example example-like" id="sec-Two-Sample-Tests-5"><h3 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">5.2.2</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h3>
<div class="para logical" id="sec-Two-Sample-Tests-5-1-1">
<div class="para">Suppose a sample of 100 people from the general population contains 10 left-handed people, and a sample of 100 patients from a carpal tunnel syndrome clinic contains 16 left-handed people. If <span class="process-math">\(\theta_1\)</span> is the proportion of left-handed people in the general population, then the maximum likelihood estimation based on our control group sample would be:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-2">
\begin{gather*}
\widehat{\theta}_1 = \frac{10}{100} = 0.1.
\end{gather*}
</div>
<div class="para">If <span class="process-math">\(\theta_2\)</span> is the proportion of left-handed people in the patient population, then the maximum likelihood estimate would be:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-4">
\begin{gather*}
\widehat{\theta}_2 = \frac{16}{100} = 0.16.
\end{gather*}
</div>
<div class="para">Write <span class="process-math">\(A_1\)</span> for the proportion of the control group sample which is left-handed and <span class="process-math">\(A_2\)</span> for the proportion of the experimental group sample. Then we can estimate the variances:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-7">
\begin{align*}
n_1 \amp = 100 \amp n_2 \amp = 100 \\
\Var(A_1) \amp = \frac{n_1 \widehat{\theta}_1(1 - \widehat{\theta}_1)}{n_1^2} \amp \Var(A_2) \amp = \frac{n_2 \widehat{\theta}_2(1 - \widehat{\theta}_2)}{n_2^2} \\
\amp = \frac{(0.1)(0.9)}{100} \amp \amp = \frac{(0.16)(0.84)}{100} \\
\amp = 0.0009 \amp \amp = 0.001344
\end{align*}
</div>
<div class="para">Now, if <span class="process-math">\(D = A_2 - A_1\text{,}\)</span> then:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-9">
\begin{gather*}
\Var(D) = \Var(A_2) + \Var(A_1),
\end{gather*}
</div>
<div class="para">however, we should pause a moment here. The null hypothesis would be that the two populations have the same statistics. That should include the same variance for an individual measurement. (The variances of <span class="process-math">\(A_1\)</span> and <span class="process-math">\(A_2\)</span> could still be different if, e.g., they were averaging over different sized samples.) So we should abandon our two distinct maximum likelihood estimates <span class="process-math">\(\widehat{\theta}_1, \widehat{\theta}_2\)</span> and instead find one estimate, <span class="process-math">\(\widehat{\theta}_0\text{,}\)</span> estimated from all collected data:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-14">
\begin{gather*}
\widehat{\theta}_0 = \frac{10 + 16}{100 + 100} = \frac{26}{200} = 0.13.
\end{gather*}
</div>
<div class="para">Then, we should recalculate the variances of <span class="process-math">\(A_1, A_2\text{:}\)</span>
</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-16">
\begin{align*}
\Var(A_1) \amp = \frac{(0.13)(0.87)}{100} = 0.001131 \\
\Var(A_2) \amp = \frac{(0.13)(0.87)}{100} = 0.001131
\end{align*}
</div>
<div class="para">Finally:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-17">
\begin{gather*}
\Var(D) = \Var(A_1) + \Var(A_2) = 0.002262.
\end{gather*}
</div>
<div class="para">Now we can apply a 1-tailed test:</div>
<div class="displaymath process-math" id="sec-Two-Sample-Tests-5-1-1-18">
\begin{align*}
\Pr(D \geq 0.06) \amp \approx \Pr\left( Z \geq \frac{0.06 - 0}{\sqrt{0.002262}}\right) \\
\amp \approx 1 - \Phi(1.27) \\
\amp \approx 1 - 0.8962 \\
\amp = 0.1038 \gt 0.05,
\end{align*}
</div>
<div class="para">so we do not reject the null hypothesis.</div>
<div class="autopermalink" data-description="Paragraph"><a href="#sec-Two-Sample-Tests-5-1-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="autopermalink" data-description="Example 5.2.2"><a href="#sec-Two-Sample-Tests-5" title="Copy heading and permalink for Example 5.2.2" aria-label="Copy heading and permalink for Example 5.2.2">🔗</a></div></article><section class="exercises" id="exercises-Two-Sample-Tests"><h3 class="heading hide-type">
<span class="type">Exercises</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber"></span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="title">Exercises</span>
</h3>
<article class="exercise exercise-like" id="exercises-Two-Sample-Tests-1"><h4 class="heading"><span class="codenumber">1<span class="period heading-divison-mark heading-divison-mark__period">.</span></span></h4>