ec728d8e52d0c226f98e1b1a3ae8e4459e6c6a38
1\documentclass[methods-collated.tex]{subfiles}
2
3\begin{document}
4
5\section{Statistics}
6
7\subsection*{Probability}
8
9\begin{align*}
10 \Pr(A \cup B) &= \Pr(A) + \Pr(B) - \Pr(A \cap B) \\
11 \Pr(A \cap B) &= \Pr(A|B) \times \Pr(B) \\
12 \Pr(A|B) &= \frac{\Pr(A \cap B)}{\Pr(B)} \\
13 \Pr(A) &= \Pr(A|B) \cdot \Pr(B) + \Pr(A|B^{\prime}) \cdot \Pr(B^{\prime})
14\end{align*}
15
16Mutually exclusive: \(\Pr(A \cap B) = 0\) \\
17
18Independent events:
19\begin{flalign*}
20 \quad \Pr(A \cap B) &= \Pr(A) \times \Pr(B)& \\
21 \Pr(A|B) &= \Pr(A) \\
22 \Pr(B|A) &= \Pr(B)
23\end{flalign*}
24
25\subsection*{Combinatorics}
26
27\begin{align*}
28 \text{Arrangements} && {n \choose k} & = \frac{n!}{(n-k)} \\
29 \text{Combinations} && {n \choose k} & = \frac{n!}{k!(n-k)!}
30\end{align*}
31
32Note \({n \choose k} = {n \choose k-1}\)
33
34\begin{cas}
35 Keyboard \(\rightarrow\) Advance \(\rightarrow\) \keystroke{nCr}/\keystroke{nPr} \\
36 \-\hspace{1em} \texttt{nCr(n, r)} or \texttt{nPr(n, r)}
37\end{cas}
38
39\subsection*{Distributions}
40
41\begin{tikzpicture}
42 \begin{axis}[axis lines=left,
43 ticks=none,
44 xmin=0,
45 ymax=0.5,
46 enlargelimits=upper,
47 ylabel={\(\Pr(X=x)\)},
48 xlabel={\(x\)},
49 every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
50 every axis y label/.style={at={(axis description cs:-0.02,0.5)}, anchor=south west, rotate=90},
51 ]
52 \fill[pattern=north east lines, pattern color=orange] (0,0) -- plot[domain=0:1.68, samples=50] function {abs(x)*exp(-x)} -- (1.68,0) -- cycle;
53 \fill[pattern=north west lines, pattern color=red] (1.68,0) -- plot[domain=1.68:5, samples=50] function {abs(x)*exp(-x)} -- (5,0) -- cycle;
54 \draw[dashed, blue, very thick] (axis cs:1.68,0) -- (axis cs:1.68,0.31) node [above, anchor=south west, black] {Median};
55 \draw[dashed, blue, very thick] (axis cs:2,0) -- (axis cs:2,0.27) node [above, anchor=west, black] {Mean};
56 \draw[dashed, blue, very thick] (axis cs:1,0) -- (axis cs:1,0.365) node [above, black] {Mode};
57 \node at (1,0.18) {\textbf{50\%}};
58 \node at (3.1,0.08) {\textbf{50\%}};
59 \addplot[thick, black, no markers, samples=200, domain=0:5] {abs(x)*exp(-x)};
60 \end{axis}
61\end{tikzpicture}
62
63\subsubsection*{Mean \(\mu\)}
64
65\begin{align*}
66 E(X) &= \frac{\Sigma \left[ x \cdot f(x) \right]}{\Sigma f} \tag{\(f =\) absolute frequency} \\
67 &= \sum_{i=1}^n \left[ x_i \cdot \Pr(X=x_i) \right] \tag{discrete}\\
68 &= \int_\textbf{X} (x \cdot f(x)) \> dx
69\end{align*}
70
71\subsubsection*{Mode}
72
73Value of \(X\) which has the highest probability
74
75\begin{itemize} \tightlist
76 \item Most popular value in discrete distributions
77 \item Must exist in distribution
78 \item Represented by local max in pdf
79 \item Multiple modes exist when \(>1 \> X\) value have equal-highest probability
80\end{itemize}
81
82\subsubsection*{Median}
83
84Value separating lower and upper half of distribution area
85
86\textbf{Continuous:}
87\[ m = X \> \text{such that} \> \int_{-\infty}^{m} f(x) \> dx = 0.5 \]
88
89\textbf{Discrete:} (not in course)
90\begin{itemize} \tightlist
91 \item Does not have to exist in distribution
92 \item Add values of \(X\) smallest to largest until sum is \(\ge 0.5\)
93 \item If \(X_1 < 0.5 < X_2\), then median is the average of \(X_1\) and \(X_2\)
94 \begin{itemize}\tightlist
95 \item If \(m > 0.5\), then value of \(X\) that is reached is the median of \(X\)
96 \end{itemize}
97\end{itemize}
98
99\subsubsection*{Variance \(\sigma^2\)}
100
101\begin{align*}
102 \operatorname{Var}(x) &= \sum_{i=1}^n p_i (x_i-\mu)^2 \\
103 &= \sum (x-\mu)^2 \times \Pr(X=x) \\
104 &= \sum x^2 \times p(x) - \mu^2 \\
105 &= \operatorname{E}(X^2) - [\operatorname{E}(X)]^2 \\
106 &= E\left[(X-\mu)^2\right]
107\end{align*}
108
109\subsubsection*{Standard deviation \(\sigma\)}
110
111\begin{align*}
112 \sigma &= \operatorname{sd}(X) \\
113 &= \sqrt{\operatorname{Var}(X)}
114\end{align*}
115
116\subsection*{Binomial distributions}
117
118Conditions for a \textit{binomial distribution}:
119\begin{enumerate} \tightlist
120 \item Two possible outcomes: \textbf{success} or \textbf{failure}
121 \item \(\Pr(\text{success})\) (=\(p\)) is constant across trials
122 \item Finite number \(n\) of independent trials
123\end{enumerate}
124
125
126\subsubsection*{Properties of \(X \sim \operatorname{Bi}(n,p)\)}
127
128\begin{align*}
129 \mu(X) &= np \\
130 \operatorname{Var}(X) &= np(1-p) \\
131 \sigma(X) &= \sqrt{np(1-p)} \\
132 \Pr(X=x) &= {n \choose x} \cdot p^x \cdot (1-p)^{n-x}
133\end{align*}
134
135\begin{cas}
136 Interactive \(\rightarrow\) Distribution \(\rightarrow\) \verb;binomialPdf;
137 \begin{description}[nosep, style=multiline, labelindent=0.5cm, leftmargin=3cm, font=\normalfont]
138 \item [x:] no. of successes
139 \item [numtrial:] no. of trials
140 \item [pos:] probability of success
141 \end{description}
142\end{cas}
143
144\subsection*{Continuous random variables}
145
146A continuous random variable \(X\) has a pdf \(f\) such that:
147
148\begin{enumerate}
149 \item \(f(x) \ge 0 \forall x \)
150 \item \(\int^\infty_{-\infty} f(x) \> dx = 1\)
151\end{enumerate}
152
153\begin{align*}
154 E(X) &= \int_\textbf{X} (x \cdot f(x)) \> dx \\
155 \operatorname{Var}(X) &= E\left[(X-\mu)^2\right]
156\end{align*}
157
158\[ \Pr(X \le c) = \int^c_{-\infty} f(x) \> dx \]
159
160\begin{cas}
161 Define piecewise functions: \\
162 \-\hspace{1em}Math3 \(\rightarrow\)
163 \begin{tikzpicture}%
164 \draw rectangle (0.5,0.5);
165 \node at (0.08,0.25) {\(\{\)};
166 \filldraw [black] (0.15, 0.4) rectangle(0.25, 0.3);
167 \draw (0.35, 0.4) rectangle(0.45, 0.3);
168 \node [font=\footnotesize] at (0.3,0.3) {\verb;,;};
169 \draw (0.15, 0.2) rectangle(0.25, 0.1);
170 \node [font=\footnotesize] at (0.3,0.1) {\verb;,;};
171 \draw (0.35, 0.2) rectangle(0.45, 0.1);
172 \end{tikzpicture}
173 % TODO: finish this section
174\end{cas}
175
176\subsection*{Two random variables \(X, Y\)}
177
178If \(X\) and \(Y\) are independent:
179\begin{align*}
180 \operatorname{E}(aX+bY) & = a\operatorname{E}(X)+b\operatorname{E}(Y) \\
181 \operatorname{Var}(aX \pm bY \pm c) &= a^2 \operatorname{Var}(X) + b^2 \operatorname{Var}(Y)
182\end{align*}
183
184\subsection*{Linear functions \(X \rightarrow aX+b\)}
185
186\begin{align*}
187 \Pr(Y \le y) &= \Pr(aX+b \le y) \\
188 &= \Pr\left(X \le \dfrac{y-b}{a}\right) \\
189 &= \int^{\frac{y-b}{a}}_{-\infty} f(x) \> dx
190\end{align*}
191
192\begin{align*}
193 \textbf{Mean:} && \operatorname{E}(aX+b) & = a\operatorname{E}(X)+b \\
194 \textbf{Variance:} && \operatorname{Var}(aX+b) &= a^2 \operatorname{Var}(X) \\
195\end{align*}
196
197\subsection*{Expectation theorems}
198
199For some non-linear function \(g\), the expected value \(E(g(X))\) is not equal to \(g(E(X))\).
200
201\begin{align*}
202 E(X^2) &= \operatorname{Var}(X) - \left[E(X)\right]^2 \\
203 E(X^n) &= \Sigma x^n \cdot p(x) \tag{non-linear} \\
204 &\ne [E(X)]^n \\
205 E(aX \pm b) &= aE(X) \pm b \tag{linear} \\
206 E(b) &= b \tag{\(\forall b \in \mathbb{R}\)}\\
207 E(X+Y) &= E(X) + E(Y) \tag{two variables}
208\end{align*}
209
210\begin{figure*}[hb]
211 \centering
212 \include{../spec/normal-dist-graph}
213\end{figure*}
214
215\subsection*{Sample mean}
216
217Approximation of the \textbf{population mean} determined experimentally.
218
219\[ \overline{x} = \dfrac{\Sigma x}{n} \]
220
221where
222\begin{description}[nosep, labelindent=0.5cm]
223 \item \(n\) is the size of the sample (number of sample points)
224 \item \(x\) is the value of a sample point
225\end{description}
226
227\begin{cas}
228 \begin{enumerate}[leftmargin=3mm]
229 \item Spreadsheet
230 \item In cell A1:\\ \path{mean(randNorm(sd, mean, sample size))}
231 \item Edit \(\rightarrow\) Fill \(\rightarrow\) Fill Range
232 \item Input range as A1:An where \(n\) is the number of samples
233 \item Graph \(\rightarrow\) Histogram
234 \end{enumerate}
235\end{cas}
236
237\subsubsection*{Sample size of \(n\)}
238
239\[ \overline{X} = \sum_{i=1}^n \frac{x_i}{n} = \dfrac{\sum x}{n} \]
240
241Sample mean is distributed with mean \(\mu\) and sd \(\frac{\sigma}{\sqrt{n}}\) (approaches these values for increasing sample size \(n\)).
242
243For a new distribution with mean of \(n\) trials, \(\operatorname{E}(X^\prime) = \operatorname{E}(X), \quad \operatorname{sd}(X^\prime) = \dfrac{\operatorname{sd}(X)}{\sqrt{n}}\)
244
245\begin{cas}
246
247 \begin{itemize}
248 \item Spreadsheet \(\rightarrow\) Catalog \(\rightarrow\) \verb;randNorm(sd, mean, n); where \verb;n; is the number of samples. Show histogram with Histogram key in top left
249 \item To calculate parameters of a dataset: Calc \(\rightarrow\) One-variable
250 \end{itemize}
251
252\end{cas}
253
254\subsection*{Population sampling}
255
256\subsubsection*{Population proportion}
257
258\[ p = \dfrac{n \text{ with attribute in population}}{\text{population size}} \]
259
260Constant for a given population.
261
262\subsection*{Sample proportion}
263
264\[ \hat{p} = \dfrac{n \text{ with attribute in sample}}{\text{sample size}} \]
265
266Varies with each sample.
267
268\subsection*{Normal distributions}
269
270
271\[ Z = \frac{X - \mu}{\sigma} \]
272
273Normal distributions must have area (total prob.) of 1 \(\implies \int^\infty_{-\infty} f(x) \> dx = 1\) \\
274\(\text{mean} = \text{mode} = \text{median}\)
275
276\begin{warning}
277 Always express \(z\) as +ve. Express confidence \textit{interval} as ordered pair.
278\end{warning}
279
280\subsection*{Confidence intervals}
281
282\begin{itemize}
283 \item \textbf{Point estimate:} single-valued estimate of the population mean from the value of the sample mean \(\overline{x}\)
284 \item \textbf{Interval estimate:} confidence interval for population mean \(\mu\)
285 \item \(C\)\% confidence interval \(\implies\) \(C\)\% of samples will contain population mean \(\mu\)
286\end{itemize}
287
288\begin{cas}
289 Menu \(\rightarrow\) Stats \(\rightarrow\) Calc \(\rightarrow\) Interval \\
290 Set \textit{Type = One-Sample Z Int} \\ \-\hspace{1em} and select \textit{Variable}
291\end{cas}
292
293\subsubsection*{95\% confidence interval}
294
295For 95\% c.i. of population mean \(\mu\):
296
297\[ x \in \left(\overline{x} \pm 1.96 \dfrac{\sigma}{\sqrt{n}} \right)\]
298
299where:
300\begin{description}[nosep, labelindent=0.5cm]
301 \item \(\overline{x}\) is the sample mean
302 \item \(\sigma\) is the population sd
303 \item \(n\) is the sample size from which \(\overline{x}\) was calculated
304\end{description}
305
306\subsubsection*{Confidence interval of \(p\) from \(\hat{p}\)}
307
308\[ x \in \left( \hat{p} \pm Z \sqrt{\dfrac{\hat{p}(1-\hat{p})}{n}} \right) \]
309
310\subsection*{Margin of error}
311
312For 95\% confidence interval of \(\mu\):
313\begin{align*}
314 M &= 1.96 \times \dfrac{\sigma}{\sqrt{n}} \\
315 &= \dfrac{1}{2} \times \text{width of c.i.} \\
316 \implies n &= \left( \dfrac{1.96 \sigma}{M} \right)^2
317\end{align*}
318
319Always round \(n\) up to a whole number of samples.
320
321\subsection*{General case}
322
323For \(C\)\% c.i. of population mean \(\mu\):
324
325\[ x \in \left( \overline{x} \pm k \dfrac{\sigma}{\sqrt{n}} \right) \]
326\hfill where \(k\) is such that \(\Pr(-k < Z < k) = \frac{C}{100}\)
327
328\begin{cas}
329 Menu \(\rightarrow\) Stats \(\rightarrow\) Calc \(\rightarrow\) Interval \\
330 Set \textit{Type = One-\colorbox{important}{Prop} Z Int} \\
331 Input x \(= \hat{p} * n\)
332\end{cas}
333
334\subsection*{Confidence interval for multiple trials}
335
336For a set of \(n\) confidence intervals (samples), there is \(0.95^n\) chance that all \(n\) intervals contain the population mean \(\mu\).
337
338\end{document}