# TOPIC 2 Random Variables.

## Presentation on theme: "TOPIC 2 Random Variables."— Presentation transcript:

TOPIC 2 Random Variables

Discrete Random Variables Continuous Random Variables

Discrete Random Variables
A numerical outcome of an experiment Example: the sum of two fair dice, count number of tails from tossing 2 coins Discrete Random Variable : Whole number (0, 1, 2, 3, etc.) Obtained by counting Usually a finite number of values : Poisson random variable is exception (∞)

Probability Mass Function (PMF)
A set of probability values List of all possible [x, P (x)] pairs x = value of random variable X (outcome) P (x) = probability associated with value Mutually exclusive (no overlap) Collectively exhaustive (nothing left out) 0 ≤ P (x) ≤ 1 for all x Also referred as discrete random probability distribution

Discrete Probability Distribution
PMF Example Experiment: Toss 2 coins. Count number of tails (as a random variable of X). All Possible Occurence Discrete Probability Distribution Random Var, x Probabilities, P(x) 0 1/4 = 0.25 1 2/4 = 0.50 2 1/4 = 0.25

Visualization of PMF Example
Listing Table { (0, .25), (1, .50), (2, .25) } # Tails f (x) Frequency P (x) 1 .25 2 .50 (x) Graph .00 .25 .50 1 2 x P(x) Formula P (x) n x!(n – x)! ! = px(1 – p)n - x Note: p = trial probability = ½ n = sample size = 2

Cumulative Distribution Functions
An alternative way of specifying the probabilistic properties of a random variable X is through the function This function is known as the cumulative distribution function of a discrete random variable

Example Suppose X has a probability mass function given by
then the cumulative distribution function F of X is given by

Summary Measures Expected value or expectation of a discrete random variable (Mean of probability distribution) : average value of the random variables (all possible values) Variance : Measures the spread or variability in the values taken by the random variable Standard Deviation The positive square root of the variance

Example x P(x) x P(x) x –  (x – ) 2 (x – ) 2 P(x) .25 .50  = 1.0
Experiment : You toss 2 coins. You’re interested in the number of tails. What are the expected value, variance, and standard deviation of this random variable, number of tails? x P(x) x P(x) x –  (x – ) 2 (x – ) 2 P(x) .25 .50 = 1.0 -1.00 1.00 .25 2 = .50  = .71 1 .50 2 .25 1.00 1.00

Exercises An office has four copying machines, and the random variable x measures how many of them are in use at a particular moment in time. Suppose that P(X=0) = 0.08, P(X=1) = 0.11, P(X=2) = 0.27, and P(X=3) = 0.33. What is P(X=4) ? What is P(X≤2) ? (Cumulative probability distribution) Four cards are labeled \$1, \$2, \$3, and \$6. A player pays \$4 selects two cards at random, and then receives the sum of the winnings indicated on the two cards. Calculate the probability mass function and the cumulative distribution functions of the net winnings. A consultant has six appointment times that are open, three on Monday and three on Tuesday. Suppose that when making an appointment a client randomly chooses one of its remaining open times, with each of those open times equally likely to be chosen. Let the random variable X be the total number of appointment that have already been made over both days at the moment when Monday’s schedule has just been completely filled What is the state space of the random variable of X Calculate the probability mass function of X What is the expected value and standard deviation of the total number of appointments that have already been made over both days at the moment when Monday’s schedule has just been completely filled?

Answers to Exercises a) b) 2) Calculation:

b) Probability Mass Function Cumulative Distribution Function c)

Continuous Random Variables
A numerical outcome of an experiment Whole or fractional number Obtained by measuring Weight of a student (e.g., 115, 156.8, etc.) Infinite number of values in interval Too many to list like a discrete random variable

Example Random Variable Possible Values Experiment Weigh 100 People
Weight 45.1, 78, ... Measure Part Life Hours 900, 875.9, ... Amount spent on food \$ amount 54.12, 42, ... Measure Time Inter-Arrival 0, 1.3, 2.78, ... Between Arrivals Time

Probability Density Functions
Defines the probabilistic properties of a continuous random variable Shows all values, x, and frequencies, f (x) f (x) is a Probability Density Function (Not Probability Random Variable) Properties Frequency (Value, Frequency) f(x) x f x dx ( ) All x 1 (Area Under Curve) a b f x ( ) a b 0, Value

f(x) x a b  Continuous Random Variable Probability P ( a  x  b ) 
dx Probability is Area Under Curve! a f(x) x a b

f(x) x a Continuous Random Variable Probability
This is in contrast to discrete random variables, which can have non zero probabilities of taking specific values. Continuous random variables can have nonzero probabilities of falling within certain continuous region (e.g. a ≤ x ≤ b) f(x) x a

Cumulative Distribution Function
The cumulative distribution function of a continuous random variable X is defined as The cumulative distribution function F(x) is a continuous non-decreasing function that takes the value 0 prior to and at the beginning of the state space and increases to a value of 1 at the end

Summary Measures Expected Value or expectation (Mean of random variable) : Weighted average of all possible values If the probability density function f(x) is symmetric then the expectation of the random variable x is equal to the point of symmetry Variance : Weighted average of squared deviation about mean Standard Deviation : Median :

Variances/Standard Deviations
Variance shows the spread or variability in the values taken by the random variable Standard deviation is often used in place of the variance to describe the spread of the distribution

Example Suppose that the diameter of a metal cylinder has a probability density function f(x) = 1.5 – 6(x – 50)2 for 49.5 ≤ x ≤ 50.5 Is this a valid probability density function? Is the probability density function symmetric? What is the point of symmetry? What is the probability that the metal cylinder has a diameter between 49.8 and 50.1 mm? What is the cumulative distribution function of the metal cylinder diameter? What is the expected diameter of the metal cylinder? What is the variance and standard deviation of the metal cylinder diameters?

Answer to the Example Is this a valid probability density function? Yes. What is the probability that the metal cylinder has a diameter between 49.8 and 50.1 mm? What is the cumulative distribution function of the metal cylinder diameter?

Answer to the Example What is the expected diameter of the metal cylinder? Is the probability density function symmetric? What is the point of symmetry? Yes. μ = 50 is the point of symmetry What is the variance and standard deviation of the metal cylinder diameters?

Answer to the Example Graphs of the example
f (x) μ = E(X) σ = 0.224 f (x) = 1.5 – 6(x – 50)2 Probability density function 49.5 50 50.5 F(x) Mean F (x) = 1.5x – 2(x – 50)3 – 74.5 1 Cumulative distribution function 0.5 49.5 50 50.5 Median

Chebyshev’s Inequality
If a random variable has a mean µ and a variance σ2, then E (x) = µ σ σ σ σ σ σ For example, taking c = 2 and 3 gives

Quantiles of Random Variables
Alternative ways of describing spread of data include determining the location of values that divide a set of observations into equal parts. The pth quantile or 100pth percentile of a random variable X with a cumulative distribution function F(x) is defined to be the value of x for which p = is called 25th percentile or lower quartile (Q1) p = is called 50th percentile or median (Q2) p = is called 75th percentile or upper quartile (Q3) Interquartile Range (IQR) = Q3 – Q1

Quantiles of Random Variables
Upper Quartile Median Lower Quartile Area = 0.25 f(x) Interquartile Range

Example A random variable X has a probability density function
What is the value of A? What is the median of X? What is the lower quartile of X? What is the upper quartile of X? What is the interquartile range? a)

Answer to the Example b) c) d) e)

Jointly Discrete Random Variables
Joint Probability Distribution Y random values Y1 Y2 Yn X random Values X1 p1,1 p1,2 p1,n X2 p2,1 p2,2 p2,n Xm pm,1 Pm,2 pm,n or Joint Cumulative Distribution Function

Marginal distribution of x Marginal distribution of y
Marginal Probability Distribution Marginal distribution of x Y random values Y1 Y2 Yn X random Values X1 p1,1 p1,2 p1,n X2 p2,1 p2,2 p2,n Xm pm,1 Pm,2 pm,n Marginal distribution of y

Marginal Probability Distribution
Expectation (Mean): Variance: Standard Deviation:

Conditional Probability Distribution
If two discrete random variables X and Y are jointly distributed, then the conditional distribution of random variable X conditional on the event Y = yj consists the probability values What is this next equation about?

Covariance and Correlation
To indicate the strength of the dependence of two random variables In practice, the most convenient way to asses the strength of the dependence between two random variable is through their Correlation The correlation takes values between -1 and 1, and the discrete random variables x and y are independent if Corr (X,Y) = 0 [or Cov(X,Y) = 0] strongly dependent if Corr (X,Y) = -1 or 1 (negatively or positively)

Example A company that services air conditioner (AC) units in residence and office blocks is interested in how to schedule its technicians in the most efficient manner. Specifically the company is interested in how long a technician takes on a visit to a particular location, and the company recognizes that this mainly depends on the manner of AC units at the location that need to be serviced Service Time (hours) 1 2 3 4 Number of AC units 0.12 0.08 0.07 0.05 0.15 0.21 0.13 0.01 0.02 Check that

Example What is the probability that a location has no more than two AC units that take no more than 2 hours to service? (Joint cumulative probability function) What are the expected number, variance and standard deviation of AC? of the service time? Service Time (hours) 1 2 3 4 Number of AC units 0.12 0.08 0.07 0.05 0.15 0.21 0.13 0.01 0.02 sum 0.32 0.57 0.11 sum 0.21 0.24 0.30 0.25

Example Is there any correlation between the number of ACs and the service hours? Positively correlated!

Example Suppose that a technician is visiting a location that is known to have three air conditioner units, what is the probability that the service time is four hours?

Linear Function of a Random Variable
If X and Y are two random variables, and For some a, b that are real number, the expectation, the variance and the standard deviation of the random variable Y are

Linear Combination of Random Variables
If X1 and X2 are two random variables, and and the variance If X1 and X2 are independent random variables so that Cov(X1,X2 ) = 0, then The standard deviation

Example Use the answers of the previous example (E(X), E(Y), E(XY), Var(X) and Var(Y)) and assume that X and Y are independent variables. Find the expectation and variance of the following random variables 2X+6Y 5X-9Y+8 From the previous example: Then,

Averaging Independent Random Variables
Suppose that X1, X2 , ..…, Xn is a sequence of independent random variables each with an expectation μ and a variance σ2, and with an average Then

Example The weight of a certain type of brick has an expectation of 1.12 kg with a standard deviation of 0.03 kg What are the expectation and variance of the average weight of 25 bricks randomly selected? How many bricks need to be selected so that their average weight has a standard deviation of no more than kg? a) Since independent variable, then b)

Any Questions ?