class: center, middle, inverse, title-slide .title[ # General random variables ] .author[ ###
MACS 33000
University of Chicago ] --- `$$\newcommand{\E}{\mathrm{E}} \newcommand{\Var}{\mathrm{Var}} \newcommand{\Cov}{\mathrm{Cov}}$$` # Misc * Assigned rooms for final exam (working on res) * Calculators: request still open--two left * Will be drafting exam questions tomorrow -- submit your questions! --- class: center, middle, inverse # Survey Results --- # Survey: Overall course is going well. Wide range of thoughts on pacing from "it's great!" to "way too fast!" * **Immediate changes**: timing of psets (next few are shorter!) * **Later changes**: revisit pre-study idea * **Eventual changes**: different classroom? * **Suggestions I'm thinking about**: TA sessions, longer but less often psets? --- # Learning objectives * Define a continuous random variable * Identify continuous random variable distributions relevant to social science * Define expected value and variance of continuous random variables * Relate continuous random variables to discrete random variables * Define cumulative distribution functions (CDFs) for continuous random variables and compare to discrete random variables * Estimate probability of events using probability density functions (PDFs) and cumulative distribution functions (CDFs) --- # Continuous random variables * Random variables that are not discrete * Approval ratings * GDP * Wait time between wars: `\(X(t) = t\)` for all `\(t\)` * Proportion of vote received: `\(X(v) = v\)` for all `\(v\)` * Many analogues to discrete probability distributions * We need calculus to answer questions about probability --- # Probability density function <img src="11-general-random-vars_files/figure-html/pdf-1.png" alt="" width="864" style="display: block; margin: auto;" /> -- What is the area under the curve under `\(f(x)\)` between `\(.5\)` and `\(2\)`? -- `$$\int_{1/2}^{2} f(x)\,dx = F(2) - F(1/2)$$` --- # Continuous random variable `\(X\)` is a **continuous random variable** if there exists a nonnegative function `\(f_X\)` defined for all `\(x \in \Re\)` having the property for any (measurable) set of real numbers `\(B\)`, `$$\Pr(X \in B) = \int_{B} f_X(x)\,dx$$` --- # Continuous random variable The probability that the value of `\(X\)` falls within an interval is `$$\Pr (a \leq X \leq b) = \int_a^b f_X(x) \,dx$$` -- Compare discrete and continuous variables. Suppose we have a probability function `\(f(x)= 1/3\)` where `\(0 < x \leq 3\)`. What is `\(p(X=x)\)`? -- * For any single value `\(a\)`, `\(\Pr (X = a) = \int_a^a f_X(x) \,dx = 0\)` -- ### Requirements to be a PDF * Non-negative * Normalization property `$$\int_{-\infty}^{\infty} f_X(x) \,dx = \Pr (-\infty \leq X \leq \infty) = 1$$` --- # Uniform random variable `$$X \sim \text{Uniform}(0,1)$$` `$$f_X(x) = \left\{ \begin{array}{ll} c & \quad \text{if } 0 \leq x \leq 1 \\ 0 & \quad \text{otherwise} \end{array}\right.$$` -- `$$1 = \int_{-\infty}^{\infty} f_X(x)\,dx = \int_0^1 c \,dx = c \int_0^1 \,dx = c$$` --- # Uniform random variable: plot <img src="11-general-random-vars_files/figure-html/unif-1.png" alt="" width="864" style="display: block; margin: auto;" /> --- # Uniform random variable `$$\begin{aligned} \Pr(X \in [0.2, 0.5]) & = \int_{0.2}^{0.5} 1 \,dx \\ & = x\big|^{0.5}_{0.2} = 0.5 - 0.2 \\ & = 0.3 \end{aligned}$$` -- `$$\begin{aligned} \Pr(X \in [0.5, 0.5]) & = \int_{0.5}^{0.5} 1\,dx \\ & = x|^{0.5}_{0.5} = 0.5 - 0.5 \\ & = 0 \end{aligned}$$` -- `$$\begin{aligned} \Pr(X \in \{[0, 0.2]\cup[0.5, 1]\}) & = \int_{0}^{0.2} 1\,dx + \int_{0.5}^{1} 1\,dx \\ & = x\big|_{0}^{0.2} + x\big|_{0.5}^{1} = 0.2 - 0 + 1 - 0.5 \\ & = 0.7 \end{aligned}$$` --- # Uniform random variable `$$f_X(x) = \left\{ \begin{array}{ll} \frac{1}{b-a} & \quad \text{if } a \leq x \leq b \\ 0 & \quad \text{otherwise} \end{array}\right.$$` --- # Continuous random variables * `\(\Pr(X = a) = 0\)` * `\(\Pr(X \in (-\infty, \infty) ) = 1\)` * If `\(F\)` is antiderivative of `\(f\)`, then `\(\Pr(X \in [c,d]) = F(d) - F(c)\)` --- class: middle, center, inverse # Having a moment --- # Moments: what they are and what they tell us Moments help us understand the shape of the distribution 1. Center (mean): `\(E[X]\)` -- the 1st raw moment 1. Width (variance): `\(E[X^2] - (E[X])^2\)` -- built from the 2nd moment 1. Lopsidedness (skew): `\(E\left[\left(\frac{X-\mu}{\sigma}\right)^3\right]\)` -- the 3rd standardized moment 1. Tail-y-ness (kurtosis): `\(E\left[\left(\frac{X-\mu}{\sigma}\right)^4\right]\)` -- the 4th standardized moment --- # Great expectations: first moment -- * Summarizing a distribution * What we can expect FROM THE DISTRIBUTION re: center, ON AVERAGE * This will give us our baseline expectation for what we *should* be observing *if* our assumptions are true --- # Expectation `$$\E[X] = \int_{-\infty}^{\infty} x f_X(x) \,dx$$` * Integration instead of summation -- * Expected value rule `$$\E[g(X)] = \int_{-\infty}^{\infty} g(x) f_X(x) \,dx$$` -- * `\(n\)`th moment = `\(\E[X^n]\)` -- * `\(\Var(X) = E[(X-\mu)^2]=E[(X - \E[X])^2] = \E[X^2] - (\E[X])^2\)` --- # Uniform random variable: Mean Start with our pdf: `\(f(x) = \frac{1}{b-a}\)` (defined over a to b). -- `$$\E[X] = \int_{-\infty}^{\infty} x f_X(x) \,dx$$` -- `$$= \int_a^b x * \frac{1}{b-a} \,dx$$` -- `$$= \frac{1}{b-a} * \frac{1}{2}x^2 \Big|_a^b$$` -- `$$= \frac{1}{b-a} * \frac{b^2 - a^2}{2}= \frac{a+b}{2}$$` --- # Uniform random variable: Mean Start with our pdf: `\(f(x) = \frac{1}{b-a}\)` (defined over a to b). `$$\mu = \frac{a+b}{2}$$` SO WHAT????? -- This is what we can anticipate as the mean of our distribution. -- On average. -- Over time. -- In the long run. --- # Uniform random variable: Variance Start with our pdf: `\(f(x) = \frac{1}{b-a}\)` (defined over a to b). We need to recall two things: the formula for `\(V(X) \text{ and } E(X)\)` `$$\E[X^2] = \int_a^b x^2 * f(x) \,dx$$` -- `$$\int_a^b x^2 * \frac{1}{b-a} \,dx$$` -- `$$= \frac{1}{b-a} \int_a^b x^2 \,dx = \frac{1}{b-a} * \frac{1}{3}x^3 \Big|_a^b$$` -- `$$= \frac{b^3 - a^3}{3(b-a)} = \frac{a^2 + ab + b^2}{3}$$` --- # Uniform random variable: Variance Cont'd So, we can just plug these values into our formula: `$$\Var(X) = \E[X^2] - (\E[X])^2 = \frac{a^2 + ab + b^2}{3} - \left( \frac{a+b}{2} \right)^2 = \frac{(b-a)^2}{12}$$` --- # Exponential random variable `$$f_X(x) = \left\{ \begin{array}{ll} \lambda e^{-\lambda x} & \quad \text{if } x \geq 0 \\ 0 & \quad \text{otherwise} \end{array}\right.$$` * `\(\lambda > 0\)` -- * NOTE: you will sometimes see this with `\(\lambda\)` replaced with `\(\frac{1}{\beta}\)`. -- * SUPER FUN NOTE: You can find its expected value yourself using integration by parts!! --- # Exponential random variable <img src="11-general-random-vars_files/figure-html/exp-rv-1.png" alt="" width="864" style="display: block; margin: auto;" /> -- `$$\E[X] = \frac{1}{\lambda}, \quad \Var(X) = \frac{1}{\lambda^2}$$` --- # Cumulative distribution function For a continuous random variable `\(X\)` define its **cumulative distribution function** (CDF) `\(F_X(x)\)` as, `$$F_X(x) = \Pr(X \leq x) = \int_{-\infty} ^{x} f_X(t) \,dt$$` --- # Uniform distribution Suppose `\(X \sim \text{Uniform}(0,1)\)` `$$\begin{aligned} F_X(x) & = \Pr(X\leq x) \\& = 0 \text{, if }x< 0 \\ & = 1 \text{, if }x >1 \\ & = x \text{, if } x \in [0,1]\end{aligned}$$` -- <img src="11-general-random-vars_files/figure-html/unif-rv-1.png" alt="" width="864" style="display: block; margin: auto;" /> --- # Properties of CDFs * `\(F_X\)` is monotonically nondecreasing * `\(F_X(x)\)` tends to `\(0\)` as `\(x \rightarrow -\infty\)`, and to `\(1\)` as `\(x \rightarrow \infty\)` * `\(F_X(x)\)` is a continuous function of `\(x\)` * If `\(X\)` is continuous, the PDF and CDF can be obtained from each other by integration or differentiation `$$F_X(x) = \int_{-\infty}^x f_X(t) \,dt, \quad f_X(x) = \frac{dF_X}{dx} (x)$$` --- # Running the CDF backwards: quantiles So far we've asked: *given a value, what's the probability?* `\(\rightarrow F(x)\)` -- Now the reverse: *given a probability, what's the value?* -- The **$p$th quantile** (or `\(100p\)`th **percentile**) of `\(X\)` is the value `\(q_p\)` with `$$F(q_p) = p \quad \Longleftrightarrow \quad q_p = F^{-1}(p)$$` -- * The **median** is `\(q_{0.5}\)`: the value with half the probability below it * `\(q_{0.25}, q_{0.75}\)` are the first and third **quartiles** * Recipe: **write down `\(F(x)\)`, set it equal to `\(p\)`, solve for `\(x\)`** -- Note the median is *not* generally `\(\E[X]\)` --- they agree only when the distribution is symmetric. --- # Normal distribution Suppose `\(X\)` is a random variable with `\(X \in \Re\)` `$$f(x) = \frac{1}{\sqrt{2\pi \sigma^2}}\exp\left(-\frac{(x - \mu)^2}{2\sigma^2}\right)$$` -- `$$X \sim \text{Normal}(\mu, \sigma^2)$$` --- # Normal distribution <img src="11-general-random-vars_files/figure-html/norm-rv-1.png" alt="" width="864" style="display: block; margin: auto;" /> --- # From pdf to CDF: the exponential `$$f_X(x) = \lambda e^{-\lambda x}, \quad x \geq 0$$` -- `$$F_X(x) = \Pr(X \leq x) = \int_{0}^{x} \lambda e^{-\lambda t} \,dt$$` -- `$$= \lambda \left[ \frac{e^{-\lambda t}}{-\lambda} \right]_0^x = -e^{-\lambda t}\Big|_0^x$$` -- `$$= -e^{-\lambda x} - (-e^{0}) = 1 - e^{-\lambda x}$$` -- * Check it: `\(F(0) = 0\)`, and `\(F(x) \rightarrow 1\)` as `\(x \rightarrow \infty\)` ✔ * And going back the other way: `\(\frac{d}{dx}\left(1 - e^{-\lambda x}\right) = \lambda e^{-\lambda x} = f_X(x)\)` --- # Exponential: pdf and CDF <img src="11-general-random-vars_files/figure-html/exp-cdf-1.png" alt="" width="864" style="display: block; margin: auto;" /> -- Interval probabilities are then just subtraction: `\(\Pr(c \leq X \leq d) = F(d) - F(c) = e^{-\lambda c} - e^{-\lambda d}\)` --- # Expected value/variance * `\(Z\)` is a standard normal distribution if `$$Z \sim \text{Normal}(0,1)$$` * CDF of `\(Z\)` `$$F_{Z}(x) = \frac{1}{\sqrt{2\pi} }\int_{-\infty}^{x} \exp(-z^2/2) \,dz$$` --- # Expected value/variance Suppose `\(Z \sim \text{Normal}(0,1)\)` * `\(Y = 2Z + 6\)` * `\(Y \sim \text{Normal}(6, 4)\)` <img src="11-general-random-vars_files/figure-html/z-norm-1.png" alt="" width="864" style="display: block; margin: auto;" /> --- # Expected value/variance If `\(Z \sim N(0,1)\)`, then `\(Y = aZ + b\)` is `$$Y \sim \text{Normal} (b, a^2)$$` -- Assume we know $$ `\begin{aligned} \E[Z] & = 0 \\ \Var(Z) & = 1 \end{aligned}` $$ -- For `\(Y \sim \text{Normal}(\mu, \sigma^2)\)` `$$\begin{aligned} \E[Y] & = \E[\sigma Z + \mu] \\& = \sigma \E[Z] + \mu \\& = \mu \\\Var(Y) & = \Var(\sigma Z + \mu) \\ & = \E[(\sigma Z + \mu)^2] - \left(\E[\sigma Z + \mu]\right)^2\\&= \sigma^2\E[Z^2] + 2\sigma\mu\E[Z] + \mu^2 - \mu^2 \\ & = \sigma^2 \Var(Z) \\ & = \sigma^2 \end{aligned}$$` --- # Standard normal distribution If `\(X\)` is a normal random variable with mean `\(\mu\)` and variance `\(\sigma^2\)`, and if `\(a \neq 0, b\)` are scalars, then the random variable `$$Y = aX + b$$` is also normal, with mean and variance `$$\E[Y] = a\mu + b, \quad \Var(Y) = a^2 \sigma^2$$` -- ### Why rely on the standard normal distribution * Normal distribution is commonly used in statistical analysis * Ease of standardization * Saves time on the calculus --- # Support for President Suppose we are interested in modeling presidential approval * `\(Y\)`: proportion of population who "approves of the job the president is doing" * Individual responses are independent and identically distributed * Average of those individual binary responses * `\(N\rightarrow \infty\)` * By Central Limit Theorem, `\(Y\)` is normally distributed $$ `\begin{aligned} Y & \sim \text{Normal}(\mu, \sigma^2) \\ f_Y(y) & = \frac{1}{\sqrt{2\pi \sigma^2}} \exp\left(-\frac{(y-\mu)^2}{2\sigma^2} \right) \end{aligned}` $$ --- # Central limit theorem --- # Back to polling: presidential approval * Suppose `\(\mu = 0.44\)` and `\(\sigma^2 = 0.0025\)` * `\(\Pr(Y\geq 0.49)\)` -- `$$\begin{aligned} \Pr(Y \geq 0.49) & = 1 - \Pr(Y \leq 0.49 ) \\& = 1 - \Pr\left(Z \leq \frac{0.49-0.44 }{0.05} \right) \\& = 1 - \frac{1}{\sqrt{2\pi} } \int_{-\infty}^{1} \exp(-z^2/2) \,dz \\& = 1 - F_{Z} (1 ) \\& = 0.159\end{aligned}$$` --- # Using the standard normal table There is no closed form for `\(\int \exp(-z^2/2)\,dz\)` --- so we look it up. The table gives `\(\Phi(z) = \Pr(Z \leq z)\)` for `\(Z \sim \text{Normal}(0,1)\)`: | `\(z\)` | 0.00 | 0.50 | 0.84 | 1.00 | 1.25 | 1.28 | 1.50 | 1.645 | 1.75 | 1.96 | 2.00 | |-----|------|------|------|------|------|------|------|-------|------|------|------| | `\(\Phi(z)\)` | .5000 | .6915 | .7995 | .8413 | .8944 | .8997 | .9332 | .9500 | .9599 | .9750 | .9772 | -- Most tables print **only positive `\(z\)`**. For negatives, use symmetry: `$$\Phi(-z) = 1 - \Phi(z)$$` -- Three moves cover essentially everything: * `\(\Pr(Z \geq z) = 1 - \Phi(z)\)` * `\(\Pr(Z \leq -z) = 1 - \Phi(z)\)` * `\(\Pr(c \leq Z \leq d) = \Phi(d) - \Phi(c)\)` --- # Standard normal: worked example What is `\(\Pr(-1.25 \leq Z \leq 1.75)\)`? -- `$$\begin{aligned} \Pr(-1.25 \leq Z \leq 1.75) & = \Phi(1.75) - \Phi(-1.25) \\ & = \Phi(1.75) - [1 - \Phi(1.25)] \\ & = 0.9599 - (1 - 0.8944) \\ & = 0.9599 - 0.1056 \\ & = 0.8543 \end{aligned}$$` <img src="11-general-random-vars_files/figure-html/normal-shade-1.png" alt="" width="864" style="display: block; margin: auto;" /> -- **And if `\(X\)` isn't standard?** Standardize first: `\(\Pr(X \leq x) = \Phi\!\left(\frac{x - \mu}{\sigma}\right)\)` --- # Gamma distribution: def We use the gamma distribution when we're looking at something that takes on positive values and is skewed (long right tail). Example: waiting time between events --- # Gamma distribution: formula Suppose `\(\alpha>0\)`. Define `\(\Gamma(\alpha)\)` as $$ `\begin{aligned} \Gamma(\alpha) &= \int_{0}^{\infty} y^{\alpha- 1} e^{-y} \,dy \\ &= (\alpha- 1)! \, \forall \alpha \in \{1, 2, 3, \ldots\} \end{aligned}` $$ -- * `\(\Gamma(\frac{1}{2}) = \sqrt{\pi}\)` <!-- --- --> <!-- # Gamma distribution: simplified formula --> <!-- Suppose we have `\(\Gamma(\alpha)\)` --> <!-- $$\begin{aligned} --> <!-- \frac{\Gamma(\alpha)}{\Gamma(\alpha)} & = \frac{\int_{0}^{\infty} y^{\alpha-1} e^{-y} dy}{\Gamma(\alpha)} \\ --> <!-- 1 & = \int_{0}^{\infty} \frac{1}{\Gamma(\alpha)} y^{\alpha-1} e^{-y} \,dy --> <!-- \end{aligned}$$ --> <!-- -- --> <!-- Set `\(X = Y/\beta\)` --> <!-- -- --> <!-- $$\begin{aligned} --> <!-- F(x) = \Pr(X \leq x) & = \Pr(Y/\beta \leq x ) \\ --> <!-- & = \Pr(Y \leq x \beta ) \\ --> <!-- & = F_{Y} (x \beta) \\ --> <!-- \frac{\partial F_{Y} (x \beta) }{\partial x} & = f_{Y} (x \beta) \beta --> <!-- \end{aligned}$$ --> <!-- -- --> <!-- `$$f(x|\alpha, \beta) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha - 1} e^{-x\beta}$$` --> --- # Gamma distribution Suppose `\(X\)` is a continuous random variable, with `\(X \geq 0\)`. `\(X\)` is a Gamma random variable if `$$f(x|\alpha, \beta) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha - 1} e^{-x\beta}$$` if `\(x\geq 0\)` and `\(0\)` otherwise -- `$$X \sim \text{Gamma}(\alpha, \beta)$$` --- # Gamma distribution Suppose `\(X \sim \text{Gamma}(\alpha, \beta)\)` `$$\begin{aligned} \E[X] & = \frac{\alpha}{\beta} \\ \Var(X) & = \frac{\alpha}{\beta^2} \end{aligned}$$` -- Suppose `\(\alpha = 1\)` and `\(\beta = \lambda\)`. If `$$\begin{aligned} X & \sim \text{Gamma}(1, \lambda) \\ f(x|1, \lambda ) & = \lambda e^{- x \lambda} \end{aligned}$$` `$$X \sim \text{Exponential}(\lambda)$$` --- # Properties of Gamma distributions Suppose we have a sequence of independent random variables, with `$$X_{i} \sim \text{Gamma}(\alpha_{i}, \beta)$$` -- Then `$$Y = \sum_{i=1}^{N} X_{i}$$` `$$Y \sim \text{Gamma}(\sum_{i=1}^{N} \alpha_{i} , \beta)$$` --- # Gamma distribution v Exponential: plot <img src="11-general-random-vars_files/figure-html/gamma-3-1.png" alt="" width="864" style="display: block; margin: auto;" /> --- # Gamma distribution <img src="11-general-random-vars_files/figure-html/gamma-5-1.png" alt="" width="864" style="display: block; margin: auto;" /> --- # Importance of the Gamma distribution * Exponential and `\(\chi^2\)` distributions are special cases of the gamma distribution * Commonly used in Bayesian statistics (conjugate prior) --- # `\(\chi^2\)` distribution Suppose `\(Z \sim \text{Normal}(0,1)\)`. Consider `\(X = Z^2\)` `$$\begin{aligned} F_{X}(x) & = \Pr(X \leq x) \\ & = \Pr(Z^2 \leq x ) \\ & = \Pr(-\sqrt{x} \leq Z \leq \sqrt{x}) \\ & = \frac{1}{\sqrt{2\pi}} \int_{-\sqrt{x}}^{\sqrt{x} } e^{-\frac{z^2}{2}} \,dz\\ & = F_{Z} (\sqrt{x}) - F_{Z} (-\sqrt{x}) \end{aligned}$$` --- # `\(\chi^2\)` distribution $$ `\begin{aligned} \frac{\partial F_{X}(x) }{\partial x } & = f_{Z} (\sqrt{x}) \frac{1}{2\sqrt{x}} + f_{Z}(-\sqrt{x}) \frac{1}{2\sqrt{x}} \\ & = \frac{1}{\sqrt{x}}\frac{1}{2 \sqrt{2\pi}} ( 2e^{-\frac{x}{2}}) \\ & = \frac{1}{\sqrt{x}}\frac{1}{\sqrt{2\pi}} ( e^{-\frac{x}{2}}) \\ & = \frac{(\frac{1}{2})^{1/2}}{\Gamma(\frac{1}{2})}\left(x^{1/2 - 1} e^{-\frac{x}{2}}\right) \end{aligned}` $$ --- # `\(\chi^2\)` distribution `$$f_X(x) = \frac{(\frac{1}{2})^{1/2}}{\Gamma(\frac{1}{2})}\left(x^{1/2 - 1} e^{-\frac{x}{2}}\right)$$` -- `$$X \sim \text{Gamma}(1/2, 1/2)$$` -- If `\(X = \sum_{i=1}^{n} Z_{i}^2\)`, `\(X \sim \text{Gamma}(n/2, 1/2)\)` --- # Quantiles: two worked examples ### Our parliamentary example: `\(F(x) = \frac{x^4}{625}\)` on `\((0,5)\)` -- `$$\frac{x^4}{625} = 0.5 \; \Rightarrow \; x^4 = 312.5 \; \Rightarrow \; x = 5(0.5)^{1/4} \approx 4.20 \text{ years}$$` -- `$$\text{25th percentile:} \quad x = 5(0.25)^{1/4} \approx 3.54 \text{ years}$$` Note `\(\E[X] = 4\)`, but the median is `\(4.20\)` --- the left skew pulls the mean below the median. -- ### The exponential: `\(F(z) = 1 - e^{-\lambda z}\)` `$$1 - e^{-\lambda q} = p \; \Rightarrow \; e^{-\lambda q} = 1-p \; \Rightarrow \; q = \frac{-\log(1-p)}{\lambda}$$` -- With `\(\lambda = 1\)`, the median is `\(\frac{-\log(0.5)}{1} \approx 0.69\)` --- well below the mean of `\(1\)`. --- # Quantiles: ex <img src="11-general-random-vars_files/figure-html/quantile-plot-1.png" alt="" width="864" style="display: block; margin: auto;" /> --- # `\(\chi^2\)` distribution Suppose `\(X\)` is a continuous random variable with `\(X\geq 0\)`, with PDF `$$f(x) = \frac{1}{2^{n/2} \Gamma(n/2) } x^{n/2 - 1} e^{-x/2}$$` `\(X\)` is a `\(\chi^2\)` distribution with `\(n\)` degrees of freedom -- `$$X \sim \chi^{2}(n)$$` --- # `\(\chi^2\)` distribution: plot ``` ## NULL ``` --- # `\(\chi^2\)` properties Suppose `\(X \sim \chi^2(n)\)` $$ `\begin{aligned} \E[X] & = \E\left[\sum_{i=1}^{N} Z_{i}^2\right] \\ & = \sum_{i=1}^{N} \E[Z_{i}^{2} ] \\ \Var(Z_{i} ) & = \E[Z_{i}^2] - \E[Z_{i}]^2\\ 1 & = \E[Z_{i}^2]- 0 \\ \E[X] & = n \end{aligned}` $$ --- # `\(\chi^2\)` properties $$ `\begin{aligned} \Var(X) & = \sum_{i=1}^{N} \Var(Z_{i}^2) \\ & = \sum_{i=1}^{N} \left(\E[Z_{i}^{4} ] - \left(\E[Z_{i}^{2}]\right)^{2} \right) \\ & = \sum_{i=1}^{N} \left(3 - 1\right ) = 2n \end{aligned}` $$ --- # Student's `\(t\)` distribution Suppose `\(Z \sim \text{Normal}(0, 1)\)` and `\(U \sim \chi^2(n)\)`. Define the random variable `\(Y\)` as, `$$Y = \frac{Z}{\sqrt{\frac{U}{n}}}$$` -- If `\(Z\)` and `\(U\)` are independent then `\(Y \sim t(n)\)`, with PDF `$$f_Y(y) = \frac{\Gamma(\frac{n+1}{2})}{\sqrt{\pi n } \Gamma(\frac{n}{2})}\left(1 + \frac{y^2}{n}\right)^{-\frac{n+1}{2}}$$` --- # Differences from the Normal distribution * Normal distribution always has the same shape once standardized * The shape of the student's `\(t\)`-distribution changes depending on the sample size * At low `\(n\)` the tails are heavier than the normal's * As `\(n \uparrow\)`, the tails thin and the distribution tightens * As `\(n \rightarrow \infty\)`, student's `\(t\)`-distribution takes on the same shape as the normal distribution --- # Differences from the Normal distribution: plot ``` ## NULL ``` --- # HOW DO I DO THIS?!!! -- In all cases with the continuous random variable, we are going to be using an integral OR a table (it just does the math for you!). You can expect to see problems where a probability distribution is given by a function (sometimes explicitly stated as a type of function (and then you need to use it) or just as the function) --- ## Example: After an election in a parliamentary system, a government (consisting of a prime minister and a cabinet) is formed by gathering the support of a majority of newly elected members of parliament. Typically a government is allowed to remain in power for a certain number of years before new elections must be called but elections can be called earlier. In Country Z, governments must call elections at least every 5 years, but they could be called sooner if there is a vote of no confidence or the prime minister dissolves the government. Let the continuous random variable `\(X\)` denote the amount of time (measured in years) between the last election and the calling of the next election. `\(X\)` has support on all real numbers between 0 and 5. Suppose we know that `\(X\)` has the probability density function `$$f(x) = \begin{cases} kx^3 & 0 < x < 5, \\ 0 & \text{otherwise} \end{cases}$$` where `\(k\)` is some constant. **Find `\(k\)`.** --- # Example: Answer **Solution:** Recall that a valid PDF must sum up to 1. So we have to find a `\(k\)` such that the integral of the PDF equals 1. `$$\begin{aligned} \int_0^5 kx^3 dx &= 1 \\ k \int_0^5 x^3 dx &= 1 \\ k \left[ \frac{x^4}{4} \right]\bigg|_0^5 &= 1 \\ k \left[ \frac{5^4}{4} - \frac{0^4}{4} \right] &= 1 \\ \frac{625k}{4} &= 1 \\ k &= \frac{4}{625} \end{aligned}$$` --- ## Other question types: * Find the CDF * What function is (description of scenario) * Does the variable fall in this range? What are the chances? --- # Recap: * Uniform `\((a,b)\)`: `\(f(x)=\frac{1}{b-a}\)`; mean `\(\frac{a+b}{2}\)`, var `\(\frac{(b-a)^2}{12}\)` * Exponential `\((\lambda)\)`: `\(f(x)=\lambda e^{-\lambda x}\)`; mean `\(\frac{1}{\lambda}\)`, var `\(\frac{1}{\lambda^2}\)` * Gamma `\((\alpha,\beta)\)`: `\(f(x)=\frac{\beta^{\alpha}}{\Gamma(\alpha)}x^{\alpha-1}e^{-\beta x}\)`; mean `\(\frac{\alpha}{\beta}\)`, var `\(\frac{\alpha}{\beta^2}\)` * Normal `\((\mu,\sigma^2)\)`: `\(f(x)=\frac{1}{\sqrt{2\pi\sigma^2}}e^{-(x-\mu)^2/(2\sigma^2)}\)`; mean `\(\mu\)`, var `\(\sigma^2\)` * $\chi^2(n) = $ Gamma$(n/2, 1/2)$; mean `\(n\)`, var `\(2n\)` * Student's `\(t(n)\)`: mean `\(0\)` for `\(n>1\)`, var `\(\frac{n}{n-2}\)` for `\(n>2\)` --- class: center, middle, inverse ## Let’s get to know each other a bit more – Name, pronouns, subfield/research area, where you are currently, something fun/interesting about you and/or your hobbies