\documentclass[a4paper]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage{array}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tcolorbox}
\usepackage{fancyhdr}
\usepackage{pgfplots}
\usepackage{tabularx}
\usepackage{keystroke}
\usepackage{listings}
\usepackage{xcolor} % used only to show the phantomed stuff
\definecolor{cas}{HTML}{e6f0fe}
\usepackage{mathtools}

\pagestyle{fancy}
\fancyhead[LO,LE]{Unit 4 Specialist --- Statistics}
\fancyhead[CO,CE]{Andrew Lorimer}

\setlength\parindent{0pt}

\begin{document}

  \title{Statistics}
  \author{}
  \date{}
  \maketitle

  \section{Linear combinations of random variables}

  \subsection*{Continuous random variables}

  A continuous random variable \(X\) has a pdf \(f\) such that:

  \begin{enumerate}
    \item \(f(x) \ge 0 \forall x \)
    \item \(\int^\infty_{-\infty} f(x) \> dx = 1\)
  \end{enumerate}

  \[ \Pr(X \le c) = \int^c_{-\infty} f(x) \> dx \]

  \subsubsection*{Linear functions \(X \rightarrow aX+b\)}

  \begin{align*}
    \Pr(Y \le y) &= \Pr(aX+b \le y) \\
    &= \Pr\left(X \le \dfrac{y-b}{a}\right) \\
    &= \int^{\dfrac{y-b}{a}}_{-\infty} f(x) \> dx
  \end{align*}

  \begin{align*}
    \textbf{Mean:} && \operatorname{E}(aX+b) & = a\operatorname{E}(X)+b \\
    \textbf{Variance:} && \operatorname{Var}(aX+b) &= a^2 \operatorname{Var}(X) \\
  \end{align*}

  \subsection*{Linear combination of two random variables}

  \begin{align*}
    \textbf{Mean:} && \operatorname{E}(aX+bY) & = a\operatorname{E}(X)+b\operatorname{E}(Y) \\
    \textbf{Variance:} && \operatorname{Var}(aX+bY) &= a^2 \operatorname{Var}(X) + b^2 \operatorname{Var}(Y) \tag{if \(X\) and \(Y\) are independent}\\
  \end{align*}

  \section{Sample mean}

  \[ \overline{x} = \dfrac{\Sigma x}{n} \]

  where \(n\) is the size of the sample (number of sample points)

  \subsubsection*{\colorbox{cas}{On CAS:}}

  \begin{enumerate}
    \item Spreadsheet
    \item In cell A1: \verb;mean(randNorm(sd, mean, sample size));
    \item Edit \(\rightarrow\) Fill \(\rightarrow\) Fill Range
    \item Input range as A1:An where \(n\) is the number of samples
    \item Graph \(\rightarrow\) Histogram
  \end{enumerate}

  \subsubsection*{Sample size of \(n\)}

  \[ \overline{X} = \sum_{i=1}^n \frac{x_i}{n} = \dfrac{\sum x}{n} \]

  Sample mean is distributed with mean \(\mu\) and sd \(\frac{\sigma}{\sqrt{n}}\)
  


\end{document}
