# Lecture_12
Author: Zheyuan Wu
Date: 2023-02-15

#### Zheyuan Wu

#### 2023-02-15

### Variance and Standard Deviation

- The variance \(\sigma_X^2\),or Var(x), of a random variable X is

\[ \begin{aligned} \sigma_X^2&=E[(X-\mu_X)^2]\\ &=E[x^2-2\mu X+\mu_X^2]\\ &=E(X^2)-2\mu_XE(X)+\mu_X^2\\ &=E(X^2)-2\mu_X^2+\mu_X^2\\ &=E(X^2)-[E(X)^2] \end{aligned} \]

square distance between the data and expected value/center

where \(\mu_x=E(X)\) is the expected value of X.

An easier formula to use is

\[ \sigma_X^2=E(X^2)-[E(X)]^2 \]

- The standard deviation of X is the positive square root of the variance:

\[ \sigma_X=\sqrt{\sigma_X^2} \]

Example: Let X be the random variable with PMF

x | -1 | 1 | 2
--- | --- | --- | ---
p(x) | 1/3 | 1/6 | 1/2

\[ E(X)=-1\times{1\over 3}+1\times{1\over 6}...={5\over 6} \]

Method 1:

\[ \begin{aligned} Var(X)=\sigma_X^2&=E[(X-E(x))^2]\\ &=(-1-{5\over 6})^2\times {1\over 3}+(1-{5\over 6})^2\times {1\over 6}+(2-{5\over 6})^2\times {1\over 2}\\ &=1.81 \end{aligned} \] Method 2:

\[ \begin{aligned} \sigma_X^2&=E(X^2)-[E(X)]^2\\ &=(-1)^2*{1\over 3}+(1)^2*{1\over 6}+(2)^2*{1\over 2}-({5\over 6})^2\\ &=2.5-({5\over 6})^2\\ &=1.81 \end{aligned} \]

For continuous variable:

Let \(X\sim U(-3,2)\). Find Var(X).

\[ E(X)=-{1\over 2}(middle~point)\\ f(x)={1\over 5},x\in[-3,2]\\ \]

\[ \begin{aligned} E(X^2)&=\int_{-\infty}^{\infty}x^2f(x)dx\\ &=\int_{-3}^{2}x^2{1\over 5}dx\\ &={1\over 15}(2^3-(-3)^2)\\ &={7\over3} \end{aligned} \]

\[ Var(X)={7\over 3}-(-{1\over 2})^2=2.08 \]

Method 2:

\[ Var(X)=\int_{-\infty}^{\infty}(x-\mu_X)^2f(x)dx=... \]

Transform of random variable

If the variance of X is \(\sigma_X^2\) and \(Y=a+bX\), then

\[ \sigma_Y^2=b^2\sigma_X^2 \]

### Population Percentiles

- For continuous random variables.

Let X be a continuous random variable with CDF F and \(\alpha\) a number between 0 and 1. the 100(1-\(\alpha\))-th percentile of X is \(x_\alpha\) such that

\[ F(x_\alpha)=P(X\le x_\alpha)=1-\alpha \]

alpha as the upper area of the probability, eg. \(x_0.05\) is the area of top 0.05, as 95th percentile

Example: Let X be a continuous random variable with PDF

\[ f(x)\begin{cases}e^{-x},~~~x>0\\0,~~~ elsewhere\end{cases} \]

Find the IQR.

\[ F(Q_1)=0.25=0.288\\ 1-e^x=0.25\\ F(Q_3)=0.75=1.386\\ 1-e^x=0.75\\ IQR=Q_3-Q_1=1.098 \]

#### Moment generating function

\[ M_x(t)=E(e^{tx}),~~~t\in(-h,h)for~some~h>0 \]

\[ M_x(0)=1\\ {dM_x(t)\over dt}=M'(0)=E({d\over dx}e_{tx})=E(xe^{tx})=E(x)\\ M^k(0)=E(x^k) \]

### Models for Discrete random variables

#### Bernoulli Distribution

- A Bernoulli trial or experiment is one whose outcome is either success or a faliure.

- A Bernoulli random variable X takes the value of 1 if the outcome is a success and 0 if the outcome is a failure.

- The probability of success is p.

- Notation: \(X\sim Bern(p).\)

The PMF:

|x|0|1| |p(x)|1-p|p|