1\documentclass[spec-collated.tex]{subfiles} 2\begin{document} 3 4 \section{Statistics} 5 6 \subsection*{Continuous random variables} 7 8 A continuous random variable \(X\) has a pdf \(f\) such that: 9 10 \begin{enumerate} 11 \item \(f(x) \ge 0 \forall x \) 12 \item \(\int^\infty_{-\infty} f(x) \> dx = 1\) 13 \end{enumerate} 14 15 \begin{align*} 16 E(X) &= \int_\textbf{X} (x \cdot f(x)) \> dx \\ 17 \operatorname{Var}(X) &= E\left[(X-\mu)^2\right] 18 \end{align*} 19 20 \[ \Pr(X \le c) = \int^c_{-\infty} f(x) \> dx \] 21 22 23 \subsection*{Two random variables \(X, Y\)} 24 25 If \(X\) and \(Y\) are independent: 26 \begin{align*} 27 \operatorname{E}(aX+bY) & = a\operatorname{E}(X)+b\operatorname{E}(Y) \\ 28 \operatorname{Var}(aX \pm bY \pm c) &= a^2 \operatorname{Var}(X) + b^2 \operatorname{Var}(Y) 29 \end{align*} 30 31 \subsection*{Linear functions \(X \rightarrow aX+b\)} 32 33 \begin{align*} 34 \Pr(Y \le y) &= \Pr(aX+b \le y) \\ 35 &= \Pr\left(X \le \dfrac{y-b}{a}\right) \\ 36 &= \int^{\frac{y-b}{a}}_{-\infty} f(x) \> dx 37 \end{align*} 38 39 \begin{align*} 40 \textbf{Mean:} && \operatorname{E}(aX+b) & = a\operatorname{E}(X)+b \\ 41 \textbf{Variance:} && \operatorname{Var}(aX+b) &= a^2 \operatorname{Var}(X) \\ 42 \end{align*} 43 44 \subsection*{Expectation theorems} 45 46 For some non-linear function \(g\), the expected value \(E(g(X))\) is not equal to \(g(E(X))\). 47 48 \begin{align*} 49 E(X^2) &= \operatorname{Var}(X) - \left[E(X)\right]^2 \\ 50 E(X^n) &= \Sigma x^n \cdot p(x) \tag{non-linear} \\ 51 &\ne [E(X)]^n \\ 52 E(aX \pm b) &= aE(X) \pm b \tag{linear} \\ 53 E(b) &= b \tag{\(\forall b \in \mathbb{R}\)}\\ 54 E(X+Y) &= E(X) + E(Y) \tag{two variables} 55 \end{align*} 56 57 \subsection*{Sample mean} 58 59 Approximation of the \textbf{population mean} determined experimentally. 60 61 \[ \overline{x} = \dfrac{\Sigma x}{n} \] 62 63 where 64 \begin{description}[nosep, labelindent=0.5cm] 65 \item \(n\) is the size of the sample (number of sample points) 66 \item \(x\) is the value of a sample point 67 \end{description} 68 69\begin{cas} 70 \begin{enumerate}[leftmargin=3mm] 71 \item Spreadsheet 72 \item In cell A1:\\ \path{mean(randNorm(sd, mean, sample size))} 73 \item Edit \(\rightarrow\) Fill \(\rightarrow\) Fill Range 74 \item Input range as A1:An where \(n\) is the number of samples 75 \item Graph \(\rightarrow\) Histogram 76 \end{enumerate} 77 \end{cas} 78 79 \subsubsection*{Sample size of \(n\)} 80 81 \[ \overline{X} = \sum_{i=1}^n \frac{x_i}{n} = \dfrac{\sum x}{n} \] 82 83 Sample mean is distributed with mean \(\mu\) and sd \(\frac{\sigma}{\sqrt{n}}\) (approaches these values for increasing sample size \(n\)). 84 85 For 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}}\) 86 87 \begin{cas} 88 89 \begin{itemize} 90 \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 91 \item To calculate parameters of a dataset: Calc \(\rightarrow\) One-variable 92 \end{itemize} 93 94 \end{cas} 95 96 \subsection*{Normal distributions} 97 98 99 \[ Z = \frac{X - \mu}{\sigma} \] 100 101 Normal distributions must have area (total prob.) of 1 \(\implies \int^\infty_{-\infty} f(x) \> dx = 1\) \\ 102 \(\text{mean} = \text{mode} = \text{median}\) 103 104 \begin{warning} 105 Always express \(z\) as +ve. Express confidence \textit{interval} as ordered pair. 106 \end{warning} 107 108 \begin{figure*}[hb] 109 \centering 110 \include{normal-dist-graph} 111 \end{figure*} 112 113 \subsection*{Central limit theorem} 114 115 If \(X\) is randomly distributed with mean \(\mu\) and sd \(\sigma\), then with an adequate sample size \(n\) the distribution of the sample mean \(\overline{X}\) is approximately normal with mean \(E(\overline{X})\) and \(\operatorname{sd}(\overline{X}) = \frac{\sigma}{\sqrt{n}}\). 116 117 \subsection*{Confidence intervals} 118 119 \begin{itemize} 120 \item \textbf{Point estimate:} single-valued estimate of the population mean from the value of the sample mean \(\overline{x}\) 121 \item \textbf{Interval estimate:} confidence interval for population mean \(\mu\) 122 \item \(C\)\% confidence interval \(\implies\) \(C\)\% of samples will contain population mean \(\mu\) 123 \end{itemize} 124 125 \subsubsection*{95\% confidence interval} 126 127 For 95\% c.i. of population mean \(\mu\): 128 129 \[ x \in \left(\overline{x} \pm 1.96 \dfrac{\sigma}{\sqrt{n}} \right)\] 130 131 where: 132 \begin{description}[nosep, labelindent=0.5cm] 133 \item \(\overline{x}\) is the sample mean 134 \item \(\sigma\) is the population sd 135 \item \(n\) is the sample size from which \(\overline{x}\) was calculated 136 \end{description} 137 138 \begin{cas} 139 Menu \(\rightarrow\) Stats \(\rightarrow\) Calc \(\rightarrow\) Interval \\ 140 Set \textit{Type = One-Sample Z Int} \\ \-\hspace{1em} and select \textit{Variable} 141 \end{cas} 142 143 \subsection*{Margin of error} 144 145 For 95\% confidence interval of \(\mu\): 146 \begin{align*} 147 M &= 1.96 \times \dfrac{\sigma}{\sqrt{n}} \\ 148 \implies n &= \left( \dfrac{1.96 \sigma}{M} \right)^2 149 \end{align*} 150 151 Always round \(n\) up to a whole number of samples. 152 153 \subsection*{General case} 154 155 For \(C\)\% c.i. of population mean \(\mu\): 156 157 \[ x \in \left( \overline{x} \pm k \dfrac{\sigma}{\sqrt{n}} \right) \] 158 \hfill where \(k\) is such that \(\Pr(-k < Z < k) = \frac{C}{100}\) 159 160 \subsection*{Confidence interval for multiple trials} 161 162 For a set of \(n\) confidence intervals (samples), there is \(0.95^n\) chance that all \(n\) intervals contain the population mean \(\mu\). 163 164 \section{Hypothesis testing} 165 166 \begin{warning} 167 Note hypotheses are always expressed in terms of population parameters 168 \end{warning} 169 170 \subsection*{Null hypothesis \(H_0\)} 171 172 Sample drawn from population has same mean as control population, and any difference can be explained by sample variations. 173 174 \subsection*{Alternative hypothesis \(H_1\)} 175 176 Amount of variation from control is significant, despite standard sample variations. 177 178 \subsection*{\(p\)-value} 179 180 181 \begin{align*} 182 p &= \Pr(\overline{X} \lessgtr \mu(H_1)) \\ 183 &= 2 \cdot \Pr(\overline{X} <> \mu(H_1) | \mu = 8) 184 \end{align*} 185 186 Probability of observing a value of the sample statistic as significant as the one observed, assuming null hypothesis is true. 187 188 \vspace{0.5em} 189 \begin{tabularx}{23em}{|l|X|} 190 \hline 191 \rowcolor{cas} 192 \(\boldsymbol{p}\) & \textbf{Conclusion} \\ 193 \hline 194 \(> 0.05\) & insufficient evidence against \(H_0\) \\ 195 \(< 0.05\) (5\%) & good evidence against \(H_0\) \\ 196 \(< 0.01\) (1\%) & strong evidence against \(H_0\) \\ 197 \(< 0.001\) (0.1\%) & very strong evidence against \(H_0\) \\ 198 \hline 199 \end{tabularx} 200 201 \subsection*{Statistical significance} 202 203 Significance level is denoted by \(\alpha\). 204 205 \-\hspace{1em} If \(p<\alpha\), null hypothesis is \textbf{rejected} \\ 206 \-\hspace{1em} If \(p>\alpha\), null hypothesis is \textbf{accepted} 207 208 \subsection*{\(z\)-test} 209 210 Hypothesis test for a mean of a sample drawn from a normally distributed population with a known standard deviation. 211 212 \begin{cas} 213 Menu \(\rightarrow\) Statistics \(\rightarrow\) Calc \(\rightarrow\) Test. \\ 214 Select \textit{One-Sample Z-Test} and \textit{Variable}, then input: 215 \begin{description}[nosep, style=multiline, labelindent=0.5cm, leftmargin=2cm, font=\normalfont] 216 \item[\(\mu\) cond:] same operator as \(H_1\) 217 \item[\(\mu_0\):] expected sample mean (null hypothesis) 218 \item[\(\sigma\):] standard deviation (null hypothesis) 219 \item[\(\overline{x}\):] sample mean 220 \item[\(n\):] sample size 221 \end{description} 222 \end{cas} 223 224 \subsection*{One-tail and two-tail tests} 225 226 \subsubsection*{One tail} 227 228 \begin{itemize} 229 \item \(\mu\) has changed in one direction 230 \item State ``\(H_1: \mu \lessgtr \) known population mean'' 231 \end{itemize} 232 233 \subsubsection*{Two tail} 234 235 \begin{itemize} 236 \item Direction of \(\Delta \mu\) is ambiguous 237 \item State ``\(H_1: \mu \ne\) known population mean'' 238 \end{itemize} 239 240 For two tail tests: 241 \begin{align*} 242 p\text{-value} &= \Pr(|\overline{X} - \mu| \ge |\overline{x}_0 - \mu|) \\ 243 &= \left( |Z| \ge \left|\dfrac{\overline{x}_0 - \mu}{\sigma \div \sqrt{n}} \right| \right) 244 \end{align*} 245 246 \subsection*{Modulus notation for two tail} 247 248 \(\Pr(|\overline{X} - \mu| \ge a) \implies\) ``the probability that the distance between \(\overline{\mu}\) and \(\mu\) is \(\ge a\)'' 249 250 \subsection*{Inverse normal} 251 252 \begin{cas} 253 \verb;invNormCdf("L", ;\(\alpha\)\verb;, ;\(\dfrac{\sigma}{n^\alpha}\)\verb;, ;\(\mu\)\verb;); 254 \end{cas} 255 256 \subsection*{Errors} 257 258 \begin{description}[labelwidth=2.5cm, labelindent=0.5cm] 259 \item [Type I error] \(H_0\) is rejected when it is \textbf{true} 260 \item [Type II error] \(H_0\) is \textbf{not} rejected when it is \textbf{false} 261 \end{description} 262 263% \subsection*{Using c.i. to find \(p\)} 264% need more here 265 266\end{document}