Topic 3 - Random Variables

Download or print notes to PDF

If you’d like to export this presentation to a PDF, do the following

  1. Toggle into Print View using the E key.
  2. Open the in-browser print dialog (CTRL/CMD+P)
  3. Change the Destination to Save as PDF.
  4. Change the Layout to Landscape.
  5. Change the Margins to None.
  6. Enable the Background graphics option.
  7. Click Save.

This feature has been confirmed to work in Google Chrome and Firefox.

Key Concepts

Random Variables

A random variable (RV) is a random process with numerical outcomes

Random indicates that a single outcome of the process is uncertain.

 

Examples:

  • The sum of the dots that appear when two fair dice are rolled.

  • The number of patients that enter a hospital waiting room in any given hour interval.

  • The daily recorded high temperature in Corvallis.

 

The support of a random variable is the set of possible outcomes the RV can take on.

Random Variables

Discrete RVs

A random variable that has a countable set of possible outcomes.

  • finite OR

  • infinite with as many elements are there are whole numbers

Continuous RVs

A random variable that has an infinite, continuous set of possible outcomes in a given interval.

Examples

DISCRETE

  1. Let the random variable \(X\) represent the number of courses a student is enrolled in at a community college. Enrollment information for the college suggests the following model for the random variable.
\(x\) 1 2 3 4 5
\(p(x)\) 0.16 0.32 0.36 0.12 0.04

 

CONTINUOUS

  1. A public library has private meeting rooms that can be reserved for up to one hour. Suppose \(X\) is the random variable that represents the amount of time the user spends in the meeting room during a reservation. \(X\) is defined on the interval [0,1] and has the following probability density function: \[ f(x) = 3x^2 \]

Discrete RVs

Probability Mass Function (PMF), \(p(x)\)

 

\(p(x)\)\(= P(X = x)\)

 

The PMF may be represented as a

  • table

  • mathematical function

 

Properties:

  • \(0 \leq p(x) \leq 1\)

  • \(\sum \limits_{i=1}^n p(x_i) =1\)

Continuous RVs

Probability Density Function (PDF), \(f(x)\)

 

\(P(c \leq X \leq d) = \int \limits_{c}^d f(x) dx\)

 

 

 

 

Properties:

  • \(f(x) \geq 0\) for all values of \(x\) in the support

  • \(\int \limits_{-\infty}^{\infty} f(x) dx = 1\)

Example - PMF

  1. Let the random variable \(X\) represent the number of courses a student is enrolled in at a community college. Enrollment information for the college suggests the following model for the random variable.
\(x\) 1 2 3 4 5
\(p(x)\) 0.16 0.32 0.36 0.12 0.04

 

\[p(2) = 0.32\]

\[p(4) = 0.12\]

Example - PDF

  1. Suppose \(X\) is the random variable that represents the amount of time the user spends in the meeting room during a reservation. \(X\) is defined on the interval [0,1] and has the following probability density function: \(f(x) = 3x^2\)

Cumulative Distribution Function (CDF)

Discrete RVs

 

\(F(x)\)\(=P(X \leq x)\)

 

\(F(x) = \sum \limits_{t\leq x}p(t)\)

Continuous RVs

 

\(F(x)\)\(=P(X \leq x)\)

 

\(F(x) = \int \limits_{-\infty}^x f(t) dt\)

 

Continuous CDF Properties:

  • \(P(a \leq X \leq b) = F(b) - F(a)\)

  • \(\frac{d}{dx}F(x) = f(x)\)

  • \(P(X \leq a) = P(X < a) = F(a)\)

Example - Discrete CDF

  1. Let the random variable \(X\) represent the number of courses a student is enrolled in at a community college. Enrollment information for the college suggests the following model for the random variable.
\(x\) 1 2 3 4 5
\(p(x)\) 0.16 0.32 0.36 0.12 0.04

 

$$F(2)=P(X \leq 2)=p(1)+p(2)=0.16+0.32=0.48$$

Example - Continuous CDF

  1. Suppose \(X\) is the random variable that represents the amount of time the user spends in the meeting room during a reservation. \(X\) is defined on the interval [0,1] and has the following probability density function: \(f(x) = 3x^2\)

\(F(x) =\)\(\int \limits_{0}^x 3t^2 dt\)\(=t^3 \bigg \vert _0^x\)\(=x^3\)

Expectation \(E(X)\)

Discrete RVs

\[E(X) = \sum \limits_{i=1}^n x_i p(x_i)\]

Continuous RVs

\[E(X) = \int \limits_{-\infty}^{\infty} x f(x) dx\]

\(-\infty\) and \(\infty\) can be replaced with the bounds of the support of \(X\).

Example - Discrete Expectation

  1. Let the random variable \(X\) represent the number of courses a student is enrolled in at a community college. Enrollment information for the college suggests the following model for the random variable.
\(x\) 1 2 3 4 5
\(p(x)\) 0.16 0.32 0.36 0.12 0.04

 

\(E(X) = 1(0.16) + 2(0.32) + 3(0.36) + 4(0.12) + 5(0.04) = 2.56\)

 

We expect a randomly selected student at the community college to be enrolled in 2.56 courses.

Example - Continuous Expectation

  1. Suppose \(X\) is the random variable that represents the amount of time the user spends in the meeting room during a reservation. \(X\) is defined on the interval [0,1] and has the following probability density function: \(f(x) = 3x^2\)

\(E(X) =\)\(\int \limits _0^1 x (3x^2) dx\)\(= \frac{3}{4}x^4 \bigg \vert_0^1\)\(= \frac{3}{4}\)

We expect a randomly selected user of the reservation system occupies the meeting room for 3/4 of an hour (or 45 minutes).

Variance and Standard Deviation

Discrete RVs

\(Var(X) = \sum \limits_{i=1}^n(x_i-E(X))^2p(x_i)\) \(=E(X^2) - (E(X))^2\)

 

\(E(X^2) = \sum \limits_{i=1}^n x_i^2 p(x_i)\)

 

Continuous RVs

\(Var(X) = \int \limits_{-\infty}^{\infty}(x-E(X))^2f(x) dx\) \(=E(X^2) - (E(X))^2\)

 

\(E(X^2) = \int \limits_{-\infty}^{\infty} x^2 f(x) dx\)

 

\(-\infty\) and \(\infty\) can be replaced with the bounds of the support of \(X\).

 

\(SD(X) = \sqrt{Var(X)}\)

Example - Discrete Var and SD

  1. Let the random variable \(X\) represent the number of courses a student is enrolled in at a community college. Enrollment information for the college suggests the following model for the random variable.
\(x\) 1 2 3 4 5
\(p(x)\) 0.16 0.32 0.36 0.12 0.04

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

\[E(X^2) = 1^2(0.16) + 2^2(0.32) + 3^2(0.36) + 4^2(0.12) + 5^2(0.04) = 7.6\]

\[Var(X) = E(X^2)-(E(X))^2 = 7.6 - 2.56^2 = 1.0464\]

\[SD(X) = \sqrt{1.0464} = 1.022937\]

A typical deviation from the expected number of enrolled courses is approximately 1.02 courses.

Example - Continuous Var and SD

  1. Suppose \(X\) is the random variable that represents the amount of time the user spends in the meeting room during a reservation. \(X\) is defined on the interval [0,1] and has the following probability density function: \(f(x) = 3x^2\)

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

\(E(X^2)=\int \limits_0^1 x^2(3x^2)dx\)\(=\frac{3}{5}x^5 \bigg \vert_0^1\)\(= \frac{3}{5}\)

\[Var(X) = E(X^2)-(E(X))^2 = \frac{3}{5} - \bigg ( \frac{3}{4}\bigg)^2 = 0.0375\]

\[SD(X) = \sqrt{0.0375} = 0.1936\]

A typical deviation from the expected time spent in the reserved meeting room is approximately 0.19 hours (or a little more than 11 minutes).

Binomial Distribution

  • When to use:

Want to model the number of successful outcomes from \(n\) independent Bernoulli trials.

  • Parameters of the distribution:

\(n=\) the number of independent Bernoulli trials

\(p=\) the probability of success on each independent trial

  • Probability Mass Function:

\[ p(x) = {{n}\choose{x}}p^x(1-p)^{n-x}\] for \(x\) in \(\{0, 1, 2, ..., n \}\)

where \({{n}\choose{x}} = \frac{n!}{x!(n-x)!}\)

  • Expectation:

\(E(X) = np\)

  • Variance:

\(Var(X) = np(1-p)\)

R Demonstration

 

Binomial Distribution

\(p(x) = P(X = x)\): dbinom(x, n, p)

\(F(x) = P(X \leq x)\): pbinom(q, n, p)