# Lecture_10
Author: Zheyuan Wu
Date: 2023-02-10

#### Zheyuan Wu

#### 2023-02-10

> The last session is review session

## Random variables

A random variable is a function that associates with number with each outcome of the sample space of a random experiment.

A discrete random variable is a random variable whose sample space has a finite or at most a countably infinite number of values

Example: Toss a fair coin and let X be the number of tosses until the third head occurs.

\[ S_X=\{3,4,5,6...\} infinite,ountable \]

A continuous random variable can take any value within a finite or infinite interval of the real number line (-\(\infty\),\(\infty\))*

### Cumulative Distribution Function

The cumulative distribution function (CDF) of a random variable X is the function \[ F(x)=P(X\leq x) \]

for \(x \in [-\infty,\infty]\) (in real number line).

### Properties of the CDF:

- It is non-decreasing: If \(a\leq b\), then \(F(a)\leq F(b)\), because \([X\leq a]\subseteq[X\leq b]\).

- \(F(-\infty)=0\) and $F()=1 $.

- If \(a< b\), then \(P(a<X\leq b)=F(b)-F(a)\).

Example: Toss a fair coin 3 times and let X be the number of heads:

Outcomes: {HHH,HHT,…TTT} |S|=8,

The PMF for x

x | 0 1 2 3

P(x)|(1/8)(3/8)(3/8)(1/8)

The CDF:

For \(x<0, F(x)=P(X\leq x)=0\);

For \(0\leq x<1, F(x)=P(X\leq x)=P(X=0)=1/8\);

For \(1\leq x<2, F(x)=P(X\leq x)=P(X=0)+P(X=1)=1/2\);

For \(2\leq x<3, F(x)=P(X\leq x)=P(X=0)+P(X=1)+P(X=2)=7/8\);

For \(3\leq x, F(x)=P(X\leq x)=P(X=0)+P(X=1)+P(X=2)+P(X=3)=1\);

### Properties of the CDF of a discreate random variable

Let \(x_1<x_2<x_3...\) denote the possible values of X. Then

- F is a step function with jumps occurring only at the values of x of \(S_X\). The size of the jump at each x of \(S_X\) equals p(x).

- The CDF can be obtained from the PMF:

\[ F(x)=\sum_{x_i\leq x}p(x_i) \]

- The PMF can be obtained from the CDF:

\[ p(x_i)=F(x_i)-F(x_i-1) for i=2,3,... \]

- The probability of $a<Xb $ is given as

\[ P(a < X \leq b)=F(b)-F(a)=\sum_{a<x_i<b}p(x_i) \]

Example: Suppose the CDF of a random variable X is given by \[ F(x)=\begin{cases}0,x<-1\\1/3,-1\leq x<1\\1/2,1\leq x<2\\1,2\leq x \end{cases} \]

The places for jump (-1,1,2) is the change of P(x)

### Density Function for a Continuous Random variable

- For a continuous random variable P(X=x)=0 for all x.

- The CDF is a continuous function.

Example: We say X is the uniform in [0,1] random variable if X has CDF

\[ F(x)=\begin{cases}0,x<0\\x,0\leq x<1\\1,1\leq x\end{cases} \]

The probability density function (PDF of a continuous random variable X is a non-negative function f such that

$P(a<X<b) $ = area under f between a and b = \(\int_a^b{f(x)dx}\)

You can also write it with equal sign because P(X=a)=P(X=b)=0

Let X be a continuous random variable with PDF f(x) and CDF F(x). Then

- \(\int_{-\infty}^{\infty}{f(x)dx}=1\)

- The CDF can be obtained form the PDF:

\[ F(x)=P(X\leq x)=\int^x_{-\infty}f(y)dy \]

- The PDF can be obtained from the CDF:

\[ f(x)={d\over{dx}}F(x) \]