Latest build deployed.

This commit is contained in:
2026-01-11 13:24:27 -05:00
parent 5f05bd0b9f
commit 63ce1d952b
674 changed files with 4797 additions and 562 deletions
Regular → Executable
+254 -27
View File
@@ -9,7 +9,7 @@
<!--******************************************-->
<!--* Authored with PreTeXt *-->
<!--* pretextbook.org *-->
<!--* Theme: default-modern *-->
<!--* Theme: boulder *-->
<!--* Palette: *-->
<!--******************************************-->
<head xmlns:og="http://ogp.me/ns#" xmlns:book="https://ogp.me/ns/book#">
@@ -101,15 +101,15 @@ eBookConfig.allow_pairs = false;
eBookConfig.enableScratchAC = false;
eBookConfig.build_info = "";
eBookConfig.python3 = null;
eBookConfig.runestone_version = '7.11.5';
eBookConfig.runestone_version = '7.11.8';
eBookConfig.jobehost = '';
eBookConfig.proxyuri_runs = '';
eBookConfig.proxyuri_files = '';
eBookConfig.enable_chatcodes = false;
</script>
<!--*** Runestone Services ***-->
<script src="_static/prefix-runtime.42217a82c75796c8.bundle.js"></script><script src="_static/prefix-723.3e6434f80549315a.bundle.js"></script><script src="_static/prefix-runestone.7e141ad8414abf4a.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.f4ab138da65f4203.css">
<script src="_static/prefix-runtime.991c135ccf182bf5.bundle.js"></script><script src="_static/prefix-723.3e6434f80549315a.bundle.js"></script><script src="_static/prefix-runestone.1c010553c35c544c.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.677a75a9120449ff.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/lib/knowl.js"></script><!--knowl.js code controls Sage Cells within knowls--><script>sagecellEvalName='Evaluate (Sage)';
</script>
</head>
@@ -129,7 +129,13 @@ eBookConfig.enable_chatcodes = false;
<ol id="searchresults" class="searchresults"></ol>
</div>
</div>
<span class="nav-other-controls"><button id="light-dark-button" class="light-dark-button button" title="Dark Mode"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe51c;</span><span class="name">Dark Mode</span></button></span><span class="treebuttons"><a class="previous-button button" href="ch-Expected-Value.html" title="Previous"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe5cb;</span><span class="name">Prev</span></a><a class="up-button button" href="ch-Expected-Value.html" title="Up"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe5ce;</span><span class="name">Up</span></a><a class="next-button button" href="sec-Variance.html" title="Next"><span class="name">Next</span><span class="icon material-symbols-outlined" aria-hidden="true">&#xe5cc;</span></a></span>
<span class="nav-other-controls"><button id="embed-button" class="embed-button button" title="Embed this page"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe86f;</span><span class="name">Embed</span></button><div class="embed-popup hidden" id="embed-popup">
<p>Copy the code below to embed this page in your own website or LMS page.</p>
<div class="embed-code-container">
<textarea class="embed-code-textbox" id="embed-code-textbox" readonly aria-label="textbox"><iframe src="https://example.com/embed" width="100%" height="1000"></iframe></textarea><button class="copy-embed-button button" id="copy-embed-button" title="Copy embed code"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe14d;</span><span class="name">Copy</span></button>
</div>
</div>
<button id="light-dark-button" class="light-dark-button button" title="Dark Mode"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe51c;</span><span class="name">Dark Mode</span></button></span><span class="treebuttons"><a class="previous-button button" href="ch-Expected-Value.html" title="Previous"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe5cb;</span><span class="name">Prev</span></a><a class="up-button button" href="ch-Expected-Value.html" title="Up"><span class="icon material-symbols-outlined" aria-hidden="true">&#xe5ce;</span><span class="name">Up</span></a><a class="next-button button" href="sec-Variance.html" title="Next"><span class="name">Next</span><span class="icon material-symbols-outlined" aria-hidden="true">&#xe5cc;</span></a></span>
</div></nav><div id="latex-macros" class="hidden-content process-math" style="display:none"><span class="process-math">\(\newcommand{\N}{\mathbb N}
\newcommand{\Z}{\mathbb Z}
\newcommand{\Q}{\mathbb Q}
@@ -144,6 +150,7 @@ eBookConfig.enable_chatcodes = false;
\DeclareMathOperator{\E}{E}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\Cov}{Cov}
\newcommand{\lt}{&lt;}
\newcommand{\gt}{&gt;}
\newcommand{\amp}{&amp;}
@@ -151,9 +158,13 @@ eBookConfig.enable_chatcodes = false;
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)</span></div>
<div class="ptx-page">
<div id="ptx-sidebar" class="ptx-sidebar"><nav id="ptx-toc" class="ptx-toc depth2 focused" data-preexpanded-levels="0" data-max-levels="2"><ul class="structural toc-item-list contains-active">
<div id="ptx-sidebar" class="ptx-sidebar"><nav id="ptx-toc" class="ptx-toc depth2"><ul class="structural toc-item-list contains-active">
<li class="toc-item toc-frontmatter"><div class="toc-title-box"><a href="frontmatter.html" class="internal"><span class="title">Front Matter</span></a></div></li>
<li class="toc-item toc-chapter">
<div class="toc-title-box"><a href="ch-Introduction.html" class="internal"><span class="codenumber">0</span> <span class="title">Introduction</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-Introduction.html" class="internal"><span class="codenumber">0.1</span> <span class="title">Introduction</span></a></div></li></ul>
</li>
<li class="toc-item toc-chapter">
<div class="toc-title-box"><a href="ch-Probability.html" class="internal"><span class="codenumber">1</span> <span class="title">Probability Theory</span></a></div>
<ul class="structural toc-item-list">
<li class="toc-item toc-section">
@@ -201,6 +212,10 @@ eBookConfig.enable_chatcodes = false;
<li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Continuous-RVs.html#exercises-Continuous-RVs" class="internal"><span class="codenumber">2.2.5</span> <span class="title">Exercises</span></a></div></li>
</ul>
</li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-Joint-Distributions.html" class="internal"><span class="codenumber">2.3</span> <span class="title">Joint Distributions</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Joint-Distributions.html#exercises-Joint-Distributions" class="internal"><span class="codenumber">2.3</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
</ul>
</li>
<li class="toc-item toc-chapter contains-active">
@@ -228,24 +243,48 @@ eBookConfig.enable_chatcodes = false;
<li class="toc-item toc-chapter">
<div class="toc-title-box"><a href="ch-Confidence-Intervals.html" class="internal"><span class="codenumber">4</span> <span class="title">Confidence Intervals</span></a></div>
<ul class="structural toc-item-list">
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-CLT.html" class="internal"><span class="codenumber">4.1</span> <span class="title">Central Limit Theorem</span></a></div></li>
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-Confidence-Intervals.html" class="internal"><span class="codenumber">4.2</span> <span class="title">Confidence Intervals</span></a></div></li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-CLT.html" class="internal"><span class="codenumber">4.1</span> <span class="title">Central Limit Theorem</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-CLT.html#exercises-CLT" class="internal"><span class="codenumber">4.1</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-Confidence-Intervals.html" class="internal"><span class="codenumber">4.2</span> <span class="title">Confidence Intervals</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Confidence-Intervals.html#exercises-Confidence-Intervals" class="internal"><span class="codenumber">4.2</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
</ul>
</li>
<li class="toc-item toc-chapter">
<div class="toc-title-box"><a href="ch-Hypothesis-Testing.html" class="internal"><span class="codenumber">5</span> <span class="title">Hypothesis Testing</span></a></div>
<ul class="structural toc-item-list">
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-One-Sample-Tests.html" class="internal"><span class="codenumber">5.1</span> <span class="title">One Sample Tests</span></a></div></li>
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-Two-Sample-Tests.html" class="internal"><span class="codenumber">5.2</span> <span class="title">Two Sample Tests</span></a></div></li>
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-Power.html" class="internal"><span class="codenumber">5.3</span> <span class="title">Power of a Test</span></a></div></li>
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-Chi-Squared.html" class="internal"><span class="codenumber">5.4</span> <span class="title"><span class="process-math">\(\chi^2\)</span> Test</span></a></div></li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-One-Sample-Tests.html" class="internal"><span class="codenumber">5.1</span> <span class="title">One Sample Tests</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-One-Sample-Tests.html#exercises-One-Sample-Tests" class="internal"><span class="codenumber">5.1</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-Two-Sample-Tests.html" class="internal"><span class="codenumber">5.2</span> <span class="title">Two Sample Tests</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Two-Sample-Tests.html#exercises-Two-Sample-Tests" class="internal"><span class="codenumber">5.2</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-Power.html" class="internal"><span class="codenumber">5.3</span> <span class="title">Power of a Test</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Power.html#exercises-Power" class="internal"><span class="codenumber">5.3</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-Chi-Squared.html" class="internal"><span class="codenumber">5.4</span> <span class="title"><span class="process-math">\(\chi^2\)</span> Test</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Chi-Squared.html#exercises-Chi-Squared" class="internal"><span class="codenumber">5.4</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
</ul>
</li>
<li class="toc-item toc-chapter">
<div class="toc-title-box"><a href="ch-Linear-Regression.html" class="internal"><span class="codenumber">6</span> <span class="title">Linear Regression</span></a></div>
<ul class="structural toc-item-list">
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-Correlation.html" class="internal"><span class="codenumber">6.1</span> <span class="title">Correlation</span></a></div></li>
<li class="toc-item toc-section"><div class="toc-title-box"><a href="sec-Linear-Regression.html" class="internal"><span class="codenumber">6.2</span> <span class="title">Linear Regression</span></a></div></li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-Correlation.html" class="internal"><span class="codenumber">6.1</span> <span class="title">Correlation</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Correlation.html#exercises-Correlation" class="internal"><span class="codenumber">6.1</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
<li class="toc-item toc-section">
<div class="toc-title-box"><a href="sec-Linear-Regression.html" class="internal"><span class="codenumber">6.2</span> <span class="title">Linear Regression</span></a></div>
<ul class="structural toc-item-list"><li class="toc-item toc-exercises"><div class="toc-title-box"><a href="sec-Linear-Regression.html#exercises-Linear-Regression" class="internal"><span class="codenumber">6.2</span> <span class="title">Exercises</span></a></div></li></ul>
</li>
</ul>
</li>
<li class="toc-item toc-backmatter"><div class="toc-title-box"><a href="backmatter.html" class="internal"><span class="title">Backmatter</span></a></div></li>
@@ -258,19 +297,19 @@ eBookConfig.enable_chatcodes = false;
</h3>
<div class="para" id="subsec-discrete-EV-2">A full probability distribution (for a discrete random variable) or a density function (for a continuous random variable) carry all of the probability information. Often, we seek <dfn class="terminology">statistics</dfn>, i.e., numbers that summarize a distribution in some way.<div class="autopermalink" data-description="Paragraph"><a href="#subsec-discrete-EV-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<article class="definition definition-like" id="def-discrete-expected-value"><h4 class="heading">
<article class="definition definition-like" id="def-discrete-EV"><h4 class="heading">
<span class="type">Definition</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.1</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para logical" id="def-discrete-expected-value-1-1">
<div class="para logical" id="def-discrete-EV-1-1">
<div class="para">Let <span class="process-math">\(X\)</span> be a discrete random variable taking the values <span class="process-math">\(x_1, x_2, \dotsc, x_n\text{.}\)</span> The <dfn class="terminology">expected value</dfn> (also called <dfn class="terminology">mean</dfn>, or <dfn class="terminology">expectation</dfn>) of <span class="process-math">\(X\)</span> is the weighted average of the values of <span class="process-math">\(X\text{,}\)</span> where the weights are the probabilities of <span class="process-math">\(X\)</span> taking each value:</div>
<div class="displaymath process-math" id="def-discrete-expected-value-1-1-9">
<div class="displaymath process-math" id="def-discrete-EV-1-1-9">
\begin{gather*}
\E(X) = \sum_{i=1}^n x_i \Pr(X = x_i).
\end{gather*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#def-discrete-expected-value-1-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
<div class="autopermalink" data-description="Paragraph"><a href="#def-discrete-EV-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="Definition 3.1.1"><a href="#def-discrete-expected-value" title="Copy heading and permalink for Definition 3.1.1" aria-label="Copy heading and permalink for Definition 3.1.1">🔗</a></div></article><article class="example example-like" id="example-EV-die"><h4 class="heading">
<div class="autopermalink" data-description="Definition 3.1.1"><a href="#def-discrete-EV" title="Copy heading and permalink for Definition 3.1.1" aria-label="Copy heading and permalink for Definition 3.1.1">🔗</a></div></article><article class="example example-like" id="example-EV-die"><h4 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.2</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para logical" id="example-EV-die-1-1">
@@ -283,9 +322,10 @@ eBookConfig.enable_chatcodes = false;
</div>
<div class="para">For example, the expected value of a fair 6-sided die roll <span class="process-math">\(R\)</span> is:</div>
<div class="displaymath process-math" id="example-EV-die-1-1-6">
\begin{gather*}
\E(R) = \frac{1 + 2 + \dotsb + 6}{6} = \frac{21}{6} = \frac{7}{2}.
\end{gather*}
\begin{align*}
\E(R) \amp = 1 \left(\frac{1}{6}\right) + 2 \left(\frac{1}{6}\right) + 3 \left(\frac{1}{6}\right) + 4 \left(\frac{1}{6}\right) + 5 \left(\frac{1}{6}\right) + 6 \left(\frac{1}{6}\right) \\
\amp = \frac{1 + 2 + \dotsb + 6}{6} = \frac{21}{6} = \frac{7}{2}.
\end{align*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#example-EV-die-1-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
@@ -376,17 +416,204 @@ eBookConfig.enable_chatcodes = false;
<div class="autopermalink" data-description="Subsection 3.1.1: Discrete Expected Value"><a href="#subsec-discrete-EV" title="Copy heading and permalink for Subsection 3.1.1: Discrete Expected Value" aria-label="Copy heading and permalink for Subsection 3.1.1: Discrete Expected Value">🔗</a></div></section><section class="subsection" id="subsec-continuous-EV"><h3 class="heading hide-type">
<span class="type">Subsection</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.2</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="title">Continuous Expected Value</span>
</h3>
<div class="para" id="subsec-continuous-EV-2"><div class="autopermalink" data-description="Paragraph"><a href="#subsec-continuous-EV-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div></div>
<div class="autopermalink" data-description="Subsection 3.1.2: Continuous Expected Value"><a href="#subsec-continuous-EV" title="Copy heading and permalink for Subsection 3.1.2: Continuous Expected Value" aria-label="Copy heading and permalink for Subsection 3.1.2: Continuous Expected Value">🔗</a></div></section><section class="subsection" id="subsec-linearity-EV"><h3 class="heading hide-type">
<div class="para" id="subsec-continuous-EV-2">Expected value for a discrete random variable is a weighted average of the values taken by the variable with weights provided by the probability distribution. Wed like to use the same idea for a continuous random variable, but now were averaging over an intervals worth of values. Also, individual values dont have probabilities, they have probability densities.<div class="autopermalink" data-description="Paragraph"><a href="#subsec-continuous-EV-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<article class="definition definition-like" id="def-continuous-EV"><h4 class="heading">
<span class="type">Definition</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.6</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para logical" id="def-continuous-EV-1-1">
<div class="para">Let <span class="process-math">\(X\)</span> be a continuous random variable taking values in the interval <span class="process-math">\([a, b]\)</span> with pdf <span class="process-math">\(f(x)\text{.}\)</span> The <dfn class="terminology">expected value</dfn> of <span class="process-math">\(X\)</span> is given by:</div>
<div class="displaymath process-math" id="def-continuous-EV-1-1-6">
\begin{gather*}
\E(X) = \int_a^b x f(x)\ dx.
\end{gather*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#def-continuous-EV-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="Definition 3.1.6"><a href="#def-continuous-EV" title="Copy heading and permalink for Definition 3.1.6" aria-label="Copy heading and permalink for Definition 3.1.6">🔗</a></div></article><div class="para" id="subsec-continuous-EV-4">Its worth viewing this definition side-by-side with <a href="sec-Expected-Value.html#def-discrete-EV" class="xref" data-knowl="./knowl/xref/def-discrete-EV.html" data-reveal-label="Reveal" data-close-label="Close" title="Definition 3.1.1">Definition 3.1.1</a> to understand that they have analogous structure. The pdf values <span class="process-math">\(f(x)\)</span> are densities, not probabilities. But the product <span class="process-math">\(f(x)\ dx\)</span> is probability. So the expression <span class="process-math">\(x f(x)\ dx\)</span> is analogous to <span class="process-math">\(x_i \Pr(X = x_i)\text{:}\)</span> value times probability. Finally, the integral symbol <span class="process-math">\(\int\)</span> is meant to look like a stretched out letter "S" because it is a form of infinite summation. So, both <span class="process-math">\(\sum x_i \Pr(X = x_i)\)</span> and <span class="process-math">\(\int_a^b x f(x)\ dx\)</span> should be understood as taking the products of values with their probabilities and then summing up those products.<div class="autopermalink" data-description="Paragraph"><a href="#subsec-continuous-EV-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="example-uniform-EV"><h4 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.7</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para logical" id="example-uniform-EV-1-1">
<div class="para">Let <span class="process-math">\(X\)</span> be uniform on the interval <span class="process-math">\([a, b]\text{.}\)</span> So <span class="process-math">\(X\)</span> has the pdf <span class="process-math">\(f(x) = \frac{1}{b - a}\text{.}\)</span> We might reasonably expect that the average value of <span class="process-math">\(X\)</span> would be the midpoint of the interval. Lets check that:</div>
<div class="displaymath process-math" id="example-uniform-EV-1-1-6">
\begin{align*}
\E(X) \amp = \int_a^b x f(x)\ dx \\
\amp = \int_a^b \frac{x}{b - a} \ dx \\
\amp = \frac{1}{b-a} \left(\frac{x^2}{2}\right)\bigg|_a^b \\
\amp = \frac{1}{b-a} \left( \frac{b^2}{2} - \frac{a^2}{2} \right) \\
\amp = \frac{1}{b - a}\left( \frac{(b - a)(b + a)}{2}\right) \\
\amp = \frac{a + b}{2}.
\end{align*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#example-uniform-EV-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 3.1.7"><a href="#example-uniform-EV" title="Copy heading and permalink for Example 3.1.7" aria-label="Copy heading and permalink for Example 3.1.7">🔗</a></div></article><article class="example example-like" id="subsec-continuous-EV-6"><h4 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.8</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para logical" id="subsec-continuous-EV-6-1-1">
<div class="para">Let <span class="process-math">\(X\)</span> take values in <span class="process-math">\([0, 4]\)</span> with pdf <span class="process-math">\(f(x) = \frac{3\sqrt{x}}{16}\text{.}\)</span>
</div>
<div class="displaymath process-math" id="subsec-continuous-EV-6-1-1-4">
\begin{align*}
\E(X) \amp = \int_0^4 x f(x)\ dx \\
\amp = \int_0^4 \frac{3x^{3/2}}{16}\ dx \\
\amp = \frac{3}{16}\left(\frac{x^{5/2}}{5/2}\right)\bigg|_0^4\\
\amp = \frac{3}{16}\left(\frac{2x^{5/2}}{5}\right)\bigg|_0^4\\
\amp = \frac{3}{40}\left(x^{5/2}\right)\bigg|_0^4\\
\amp = \frac{3}{40}(32 - 0) \\
\amp = \frac{12}{5} \\
\amp = 2.4.
\end{align*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#subsec-continuous-EV-6-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 3.1.8"><a href="#subsec-continuous-EV-6" title="Copy heading and permalink for Example 3.1.8" aria-label="Copy heading and permalink for Example 3.1.8">🔗</a></div></article><div class="autopermalink" data-description="Subsection 3.1.2: Continuous Expected Value"><a href="#subsec-continuous-EV" title="Copy heading and permalink for Subsection 3.1.2: Continuous Expected Value" aria-label="Copy heading and permalink for Subsection 3.1.2: Continuous Expected Value">🔗</a></div></section><section class="subsection" id="subsec-linearity-EV"><h3 class="heading hide-type">
<span class="type">Subsection</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.3</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="title">Linearity of Expected Value</span>
</h3>
<div class="para" id="subsec-linearity-EV-2"><div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div></div>
<div class="autopermalink" data-description="Subsection 3.1.3: Linearity of Expected Value"><a href="#subsec-linearity-EV" title="Copy heading and permalink for Subsection 3.1.3: Linearity of Expected Value" aria-label="Copy heading and permalink for Subsection 3.1.3: Linearity of Expected Value">🔗</a></div></section><section class="exercises" id="exercises-Expected-Value"><h3 class="heading hide-type">
<div class="para logical" id="subsec-linearity-EV-2">
<div class="para">In the context of many areas of mathematics, the word "linearity" doesnt refer to some graph being a straight line. Rather, it refers to a situation in which some mathematical object or operation behaves in the nicest possible way under the operations of addition and scalar multiplication (i.e., multiplication by a constant). Youve already encountered linearity several times in Calculus 1, whether or not it was phrased that way.</div>
<ul class="disc" id="subsec-linearity-EV-2-1">
<li id="subsec-linearity-EV-2-1-1">
<div class="para logical" id="subsec-linearity-EV-2-1-1-1">
<div class="para">Limits are linear:</div>
<div class="displaymath process-math" id="subsec-linearity-EV-2-1-1-1-1">
\begin{align*}
\lim f(x) + g(x) \amp = \lim f(x) + \lim g(x)\\
\lim c f(x) \amp = c \lim f(x)
\end{align*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-2-1-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="Item"><a href="#subsec-linearity-EV-2-1-1" title="Copy heading and permalink for Item" aria-label="Copy heading and permalink for Item">🔗</a></div>
</li>
<li id="subsec-linearity-EV-2-1-2">
<div class="para logical" id="subsec-linearity-EV-2-1-2-1">
<div class="para">Derivatives are linear:</div>
<div class="displaymath process-math" id="subsec-linearity-EV-2-1-2-1-1">
\begin{align*}
\frac{d}{dx}(f(x) + g(x)) \amp = \frac{d}{dx}(f(x)) + \frac{d}{dx}(g(x))\\
\frac{d}{dx}(c f(x)) \amp = c \frac{d}{dx}(f(x))
\end{align*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-2-1-2-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="autopermalink" data-description="Item"><a href="#subsec-linearity-EV-2-1-2" title="Copy heading and permalink for Item" aria-label="Copy heading and permalink for Item">🔗</a></div>
</li>
<li id="subsec-linearity-EV-2-1-3">
<div class="para logical" id="subsec-linearity-EV-2-1-3-1">
<div class="para">Integrals (both definite and indefinite) are linear:</div>
<div class="displaymath process-math" id="subsec-linearity-EV-2-1-3-1-1">
\begin{align*}
\int f(x) + g(x) \amp = \int f(x) + \int g(x)\\
\int c f(x) \amp = c \int f(x)
\end{align*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-2-1-3-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="autopermalink" data-description="Item"><a href="#subsec-linearity-EV-2-1-3" title="Copy heading and permalink for Item" aria-label="Copy heading and permalink for Item">🔗</a></div>
</li>
</ul>
<div class="para">Now, we see that expected value is also linear:</div>
<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<article class="theorem theorem-like" id="thm-linearity-of-EV"><h4 class="heading">
<span class="type">Theorem</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.9</span><span class="period heading-divison-mark heading-divison-mark__period">.</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="title">Linearity of Expectation.</span>
</h4>
<div class="para logical" id="thm-linearity-of-EV-2-1">
<div class="para">Let <span class="process-math">\(X\)</span> and <span class="process-math">\(Y\)</span> be random variables and <span class="process-math">\(\alpha \in \R\text{.}\)</span> Then:</div>
<div class="displaymath process-math" id="thm-linearity-of-EV-2-1-4">
\begin{align*}
\E(X + Y) \amp = \E(X) + \E(Y) \\
\E(\alpha X) \amp = \alpha \E(X)
\end{align*}
</div>
<div class="autopermalink" data-description="Paragraph"><a href="#thm-linearity-of-EV-2-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="autopermalink" data-description="Theorem 3.1.9: Linearity of Expectation"><a href="#thm-linearity-of-EV" title="Copy heading and permalink for Theorem 3.1.9: Linearity of Expectation" aria-label="Copy heading and permalink for Theorem 3.1.9: Linearity of Expectation">🔗</a></div></article><div class="para" id="subsec-linearity-EV-4">Some application of the linearity of expectation will seem entirely reasonable:<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-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="example-EV-sum-n-dice"><h4 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.10</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para logical" id="example-EV-sum-n-dice-1-1">
<div class="para">In <a href="sec-Expected-Value.html#example-EV-die" class="xref" data-knowl="./knowl/xref/example-EV-die.html" data-reveal-label="Reveal" data-close-label="Close" title="Example 3.1.2">Example 3.1.2</a>, we saw that the expected value of a fair 6-sided die roll is 3.5. In <a href="sec-Expected-Value.html#example-EV-sum-2-dice" class="xref" data-knowl="./knowl/xref/example-EV-sum-2-dice.html" data-reveal-label="Reveal" data-close-label="Close" title="Example 3.1.3">Example 3.1.3</a>, we saw that the expected value of the sum of two die rolls is 7, which is precisely 2 times 3.5. The calculation in <a href="sec-Expected-Value.html#example-EV-sum-2-dice" class="xref" data-knowl="./knowl/xref/example-EV-sum-2-dice.html" data-reveal-label="Reveal" data-close-label="Close" title="Example 3.1.3">Example 3.1.3</a> would be very tedious to recreate for three die rolls, let alone generalizing for <span class="process-math">\(n\)</span> rolls. However, suppose we define separate random variables <span class="process-math">\(R_1, R_2, \dotsc, R_n\)</span> for the result of each individual roll. Let <span class="process-math">\(S\)</span> be the sum of the <span class="process-math">\(n\)</span> rolls. Then <span class="process-math">\(S = R_1 + R_2 + \dotsb + R_n.\)</span> By linearity:</div>
<div class="displaymath process-math" data-contains-math-knowls="./knowl/xref/example-EV-die.html ./knowl/xref/example-EV-sum-2-dice.html ./knowl/xref/example-EV-sum-2-dice.html" id="example-EV-sum-n-dice-1-1-9">
\begin{align*}
\E(S) \amp = \E(R_1 + R_2 + \dotsb + R_n) \\
\amp = \E(R_1) + \E(R_2) + \dotsb + \E(R_n) \\
\amp = \underbrace{3.5 + 3.5 + \dotsb + 3.5}_{n \text{ times}} \\
\amp = 3.5n.
\end{align*}
</div>
<div class="para">For two rolls, we recover our previous result: <span class="process-math">\(3.5(2) = 7.\)</span> But now we have a general formula that tells the expected sum for any number of rolls. It also gives a perfectly reasonable answer: the expected sum of <span class="process-math">\(n\)</span> rolls is <span class="process-math">\(n\)</span> times the expected value of a single roll.</div>
<div class="autopermalink" data-description="Paragraph"><a href="#example-EV-sum-n-dice-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 3.1.10"><a href="#example-EV-sum-n-dice" title="Copy heading and permalink for Example 3.1.10" aria-label="Copy heading and permalink for Example 3.1.10">🔗</a></div></article><article class="example example-like" id="example-binomial-EV"><h4 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.11</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para logical" id="example-binomial-EV-1-1">
<div class="para">Suppose <span class="process-math">\(S \sim \Bin(n, p)\text{.}\)</span> <a href="sec-Discrete-RVs.html#def-binomial-distribution" class="xref" data-knowl="./knowl/xref/def-binomial-distribution.html" data-reveal-label="Reveal" data-close-label="Close" title="Definition 2.1.6">Definition 2.1.6</a> describes a binomially distributed random variable as counting the number of occurrences of some event, which either happens or not in each of <span class="process-math">\(n\)</span> independent trials. This leads us to a very natural idea: identify each individual possible occurrence of the event, and assign it an indicator random variable. In this case, let <span class="process-math">\(H_i\)</span> indicate that flip <span class="process-math">\(i\)</span> comes up heads. Then</div>
<div class="displaymath process-math" data-contains-math-knowls="./knowl/xref/def-binomial-distribution.html ./knowl/xref/example-indicator-EV.html" id="example-binomial-EV-1-1-6">
\begin{gather*}
S = H_1 + H_2 + \dotsb + H_n.
\end{gather*}
</div>
<div class="para">We already know (<a href="sec-Expected-Value.html#example-indicator-EV" class="xref" data-knowl="./knowl/xref/example-indicator-EV.html" data-reveal-label="Reveal" data-close-label="Close" title="Example 3.1.5">Example 3.1.5</a>) that the expected value of each <span class="process-math">\(H_i\)</span> is the probability of the indicated event—that flip <span class="process-math">\(i\)</span> is heads. This is precisely the parameter <span class="process-math">\(p\text{.}\)</span> Therefore:</div>
<div class="displaymath process-math" data-contains-math-knowls="./knowl/xref/def-binomial-distribution.html ./knowl/xref/example-indicator-EV.html" id="example-binomial-EV-1-1-12">
\begin{align*}
\E(S) \amp = \E(H_1 + H_2 + \dotsb + H_n) \\
\amp = \E(H_1) + \E(H_2) + \dotsb + \E(H_n) \\
\amp = \underbrace{p + p + \dotsb + p}_{n \text{ times}} \\
\amp = np.
\end{align*}
</div>
<div class="para">Remember this formula! Well make frequent use of it.</div>
<div class="autopermalink" data-description="Paragraph"><a href="#example-binomial-EV-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 3.1.11"><a href="#example-binomial-EV" title="Copy heading and permalink for Example 3.1.11" aria-label="Copy heading and permalink for Example 3.1.11">🔗</a></div></article><div class="para" id="subsec-linearity-EV-7">The previous examples are so reasonable it may seem unimpressive. But consider the following use of linearity:<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-7" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<article class="example example-like" id="subsec-linearity-EV-8"><h4 class="heading">
<span class="type">Example</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.12</span><span class="period heading-divison-mark heading-divison-mark__period">.</span>
</h4>
<div class="para" id="subsec-linearity-EV-8-1-1">We say a flip sequence has a <dfn class="terminology">run of 4 heads starting at <span class="process-math">\(k\)</span></dfn> if flips <span class="process-math">\(k, k+1, k+2, k+3\)</span> are all heads. We dont care about overlaps: the flip sequence <span class="process-math">\(HHHHH\)</span> has a run of 4 heads starting at 1 and another run starting at 2.<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-8-1-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div> <div class="para" id="subsec-linearity-EV-8-1-2">Suppose we flip a fair coin 100 times. How many runs of 4 heads should we expect?<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-8-1-2" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="solutions">
<details id="subsec-linearity-EV-8-2" class="hint solution-like born-hidden-knowl"><summary class="knowl__link"><span class="type">Hint</span><span class="period heading-divison-mark heading-divison-mark__period">.</span></summary><div class="hint solution-like knowl__content">
<div class="para" id="subsec-linearity-EV-8-2-1">Can you mimic the structure of <a href="sec-Expected-Value.html#example-binomial-EV" class="xref" data-knowl="./knowl/xref/example-binomial-EV.html" data-reveal-label="Reveal" data-close-label="Close" title="Example 3.1.11">Example 3.1.11</a>?<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-8-2-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="autopermalink" data-description="Hint 3.1.12.1"><a href="#subsec-linearity-EV-8-2" title="Copy heading and permalink for Hint 3.1.12.1" aria-label="Copy heading and permalink for Hint 3.1.12.1">🔗</a></div>
</div></details><details id="subsec-linearity-EV-8-3" class="solution solution-like born-hidden-knowl"><summary class="knowl__link"><span class="type">Solution</span><span class="period heading-divison-mark heading-divison-mark__period">.</span></summary><div class="solution solution-like knowl__content">
<div class="para logical" id="subsec-linearity-EV-8-3-1">
<div class="para">Let <span class="process-math">\(R_k\)</span> indicate a run of 4 heads starting at <span class="process-math">\(k\text{.}\)</span> Since this requires 4 precise flips to come up heads, the probability of the indicated event should be</div>
<div class="displaymath process-math" data-contains-math-knowls="./knowl/xref/example-binomial-EV.html" id="subsec-linearity-EV-8-3-1-3">
\begin{gather*}
\left(\frac{1}{2}\right)^4 = \frac{1}{16}
\end{gather*}
</div>
<div class="para">The very last starting flip for a run of 4 heads is flip number 97 (so that flips 97, 98, 99, and 100 would all be heads). Then <span class="process-math">\(S = R_1 + R_2 + \dotsb + R_{97}\)</span> precisely counts the number of runs of 4 heads. Using linearity:</div>
<div class="displaymath process-math" data-contains-math-knowls="./knowl/xref/example-binomial-EV.html" id="subsec-linearity-EV-8-3-1-5">
\begin{align*}
\E(S) \amp = \E(R_1 + R_2 + \dotsb + R_{97}) \\
\amp = \E(R_1) + \E(R_2) + \dotsb + \E(R_{97}) \\
\amp = \underbrace{\frac{1}{16} + \frac{1}{16} + \dotsb + \frac{1}{16}}_{97 \text{ times}} \\
\amp = \frac{97}{16} \\
\amp \approx 6.
\end{align*}
</div>
<div class="para">Notice that, unlike <a href="sec-Expected-Value.html#example-binomial-EV" class="xref" data-knowl="./knowl/xref/example-binomial-EV.html" data-reveal-label="Reveal" data-close-label="Close" title="Example 3.1.11">Example 3.1.11</a>, the events being indicated here are <em class="emphasis">not</em> independent from each other. Linearity is unaffected by the fact that that the runs of heads can overlap.</div>
<div class="autopermalink" data-description="Paragraph"><a href="#subsec-linearity-EV-8-3-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div>
<div class="autopermalink" data-description="Solution 3.1.12.1"><a href="#subsec-linearity-EV-8-3" title="Copy heading and permalink for Solution 3.1.12.1" aria-label="Copy heading and permalink for Solution 3.1.12.1">🔗</a></div>
</div></details>
</div>
<div class="autopermalink" data-description="Example 3.1.12"><a href="#subsec-linearity-EV-8" title="Copy heading and permalink for Example 3.1.12" aria-label="Copy heading and permalink for Example 3.1.12">🔗</a></div></article><div class="autopermalink" data-description="Subsection 3.1.3: Linearity of Expected Value"><a href="#subsec-linearity-EV" title="Copy heading and permalink for Subsection 3.1.3: Linearity of Expected Value" aria-label="Copy heading and permalink for Subsection 3.1.3: Linearity of Expected Value">🔗</a></div></section><section class="exercises" id="exercises-Expected-Value"><h3 class="heading hide-type">
<span class="type">Exercises</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.4</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-Expected-Value-1"><h4 class="heading"><span class="codenumber">1<span class="period heading-divison-mark heading-divison-mark__period">.</span></span></h4>
<div class="para" id="exercises-Expected-Value-1-1-1">Consider a random variable <span class="process-math">\(X\)</span> with probability distribution below. Find <span class="process-math">\(\E(X)\text{.}\)</span><div class="autopermalink" data-description="Paragraph"><a href="#exercises-Expected-Value-1-1-1" title="Copy heading and permalink for Paragraph" aria-label="Copy heading and permalink for Paragraph">🔗</a></div>
</div> <figure class="table table-like" id="exercises-Expected-Value-1-1-2"><figcaption><span class="type">Table</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.6<span class="period heading-divison-mark heading-divison-mark__period">.</span></span><span class="space heading-divison-mark heading-divison-mark__space"> </span><div class="autopermalink" data-description="Table 3.1.6: "><a href="#exercises-Expected-Value-1-1-2" title="Copy heading and permalink for Table 3.1.6: " aria-label="Copy heading and permalink for Table 3.1.6: ">🔗</a></div></figcaption><div class="tabular-box natural-width"><table class="tabular">
</div> <figure class="table table-like" id="exercises-Expected-Value-1-1-2"><figcaption><span class="type">Table</span><span class="space heading-divison-mark heading-divison-mark__space"> </span><span class="codenumber">3.1.13<span class="period heading-divison-mark heading-divison-mark__period">.</span></span><span class="space heading-divison-mark heading-divison-mark__space"> </span><div class="autopermalink" data-description="Table 3.1.13: "><a href="#exercises-Expected-Value-1-1-2" title="Copy heading and permalink for Table 3.1.13: " aria-label="Copy heading and permalink for Table 3.1.13: ">🔗</a></div></figcaption><div class="tabular-box natural-width"><table class="tabular">
<tr class="header-horizontal">
<th scope="col" class="c m b1 r0 l0 t0 lines"><span class="process-math">\(x\)</span></th>
<th scope="col" class="c m b1 r0 l0 t0 lines"><span class="process-math">\(\Pr(X = x)\)</span></th>