Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Lecture 3: Random Variables Readings: Sections 1.3, 1.6, 2.1, 2.2 1 Introduction Random Variables • Random variable (rv): a real-valued function whose domain is a sample space. • Notation: – Capital letters X, Y, Z for random variables – Lower case letters x, y, z for specific values that a random variable might take Example 1: Toss a fair coin twice. Let X be the number of heads Discrete vs. Continuous Random Variable • Discrete random variable: a random variable that can take on only finite or countable number of possible values • Continuous random variable: a random variable that can take on any value in an interval Example 2: Identify which of the following random variables are discrete and which are continuous – X = the number of tosses if you toss a coin until getting a head – X = lifetime of a light bulb – X = number of phone calls a receptionist receives in an hour – X = number of hearts if you select 10 cards at random from a deck of 52 cards – X = height of a Purdue female student 2 Discrete Random Variables Probability Mass Function (PMF) p(x) • The probability mass function p(x) of a discrete random variable X is a function that is defined for every possible value x, i.e., p(x) = P (X = x) – 0 ≤ p(x) ≤ 1 P p(x) = 1 – x 1 – P (a ≤ X ≤ b) = P p(x) a≤x≤b Example 3: I have an unbalanced die with probabilities: x p(x) 1 0.01 2 0.02 3 0.1 4 0.2 5 0.3 6 0.37 Roll the die once and let X be the number that was recorded. Find the following probabilities: – P (2 ≤ X < 5) – P (X is even) Example 4: Let X be a discrete random variable with the following PMF: 1 14 (x + 1)2 x = 0, 1, 2 p(x) = 0 otherwise – P (X = 1) = – P (X < 2) = – P (X = 4) = Expected Value (Mean) • The expected value of a discrete random variable X with PMF p(x) is given by X E(X) = xp(x), x where summation is over all possible values x • Note: The mean is often denoted as µ, µX , E(X), E[X], E{X} Example 5: X is a discrete random variable with the following PMF: x p(x) 0 0.1 Find the mean of X. 2 1 0.5 2 0.4 Variance and Standard Deviation • The variance of a discrete random variable X with PMF p(x) is given by X V ar(X) = (x − E(X))2 p(x), x where the summation is over all possible values x. p • The standard deviation SD(X) = V ar(X) • Note: 2 , V ar(X), V (X) – The variance is often denoted as σ 2 , σX – The standard deviation is often denoted as σ, σX , SD(X) Example 5 (cont’d): Find the variance and standard deviation of X. Properties of Mean Let c be a constant, a. E(X + c) = E(X) + c b. E(cX) = cE(X) c. The expected values of a sum is the sum of the expected values E(X + Y ) = E(X) + E(Y ) E(X1 + X2 + . . . + Xn ) = E(X1 ) + E(X2 ) + . . . + E(Xn ) d. E(c) = c Example 6: Suppose that the mean of X is 10 and the mean of Y is 2. Find the mean of W = 3X − 2Y + 2 3 Properties of Variance and Standard Deviation Let c be a constant, a. V ar(X + c) = V ar(X) and SD(X + c) = SD(X) b. V ar(cX) = c2 V ar(X) and SD(cX) = |c|SD(X) c. The variance of a sum of independent random variables is the sum of the variances ∗ If X and Y are independent, then V ar(X + Y ) =p V ar(X) + V ar(Y ) SD(X + Y ) = V ar(X) + V ar(Y ) ∗ If X1 , X2 , . . . , Xn are independent, then V ar(X1 + X2 + . . . + Xn ) =p V ar(X1 ) + V ar(X2 ) + . . . + V ar(Xn ) SD(X1 + X2 + . . . + Xn ) = V ar(X1 ) + V ar(X2 ) + . . . + V ar(Xn ) d. V ar(c) = 0 and SD(c) = 0 Example 7: Suppose that the variance of X is 5, the variance of Y is 10, and X and Y are independent. Find the variance and standard deviation of W = 3X − 2Y + 2 Binomial Distribution • Binomial experiment – A fixed number n of identical trials – The trials are independent – Two possible outcomes for each trial, success and failure – Probability of success p is constant for all trials • Binomial random variable: If X is the number of successes in a binomial experiment, then X is a binomial random variable with parameters n and p, i.e., X ∼ binomial(n, p). • The PMF for a binomial rv: for X ∼ binomial(n, p), n px (1 − p)n−x x = 0, 1, 2, . . . , n x p(x) = 0 otherwise n n n! Here reads “n choose x” and = x!(n−x)! x x – Mean: E(X) = np 4 – Variance: V ar(X) = np(1 − p) Example 8: Roll a balanced die 10 times and let X be the number of times a “3” is rolled. – What is the probability that exactly two “3”s are rolled? – What is the probability that at most two “3”s are rolled? Poisson Distribution • Poisson Distribution are often used to model number of times some “event” occurs during a specified time or in a particular region or space. For example, – number of times a machine fails in the course of a workday – number of bacteria colonies in a cubic centimeter of water • Poisson random variable: If X is the number of events in a particular time or region and λ > 0 is the average number of events in that time or region, then X is a Poisson random variable with parameter λ. • The PMF for a Poisson rv: for X ∼ Poisson(λ), λx e−λ x = 0, 1, 2, . . . x! p(x) = 0 otherwise where 0! = 1. – Mean: E(X) = λ – Variance: V ar(X) = λ Example 9: The receptionist in the main office of Statistics Department receives an average of 5 calls in an hour. – What is the probability that there will be exactly two calls in the next hour? – What is the probability that there will be at most two calls in the next hour? 5 – What is the probability that there will be exactly five calls in the next two hours? 3 Continuous Random Variables Probability Density Function (PDF) f (x) The probability density function f (x) of a continuous random variable X is a function such that for any two numbers a and b (a ≤ b), Zb P (a ≤ X ≤ b) = f (x)dx a In other words, the probability that X falls in [a, b] is the area under the function f (x) above this interval a b Important properties of PDF • f (x) ≥ 0; a PDF is a non-negative function • R∞ f (x)dx = 1; the area under the curve must be 1 −∞ • For any specific value c, P (X = c) = 0 • For any a < b, P (a ≤ X ≤ b) = P (a < X < b) = Rb a 6 f (x)dx Expected Value • The expected value of a continuous random variable X with PDF f (x) is given by Z∞ E(X) = xf (x)dx, −∞ Example 10: X is a continuous random variable with the following PDF: 3x2 0 < x < 1 0 otherwise f (x) = Find the mean of X. Variance and Standard Deviation • The variance of a continuous random variable X with PDF f (x) is given by Z∞ V ar(X) = (x − E(X))2 f (x)dx, −∞ Example 10 (cont’d): Find the variance and standard deviation of X. Special Continuous Distributions • Exponential distribution with parameter λ (λ > 0): λe−λx x > 0 f (x) = 0 otherwise – E(X) = 1 λ – V ar(X) = 1 λ2 • Normal distribution with parameters µ and σ: f (x) = √ 7 1 2πσ 2 e− (x−µ)2 2σ 2 – E(X) = µ – V ar(X) = σ 2 Exponential PDF Normal PDF Example 11: Suppose that a random variable X has a probability density function given by cx(1 − x) 0 ≤ x ≤ 1 f (x) = 0 otherwise – Find the value of c – Find P (0.4 ≤ X ≤ 1) – Find P (X ≤ 0.4|X ≤ 0.8) – Find P (X > 0.4|X ≤ 0.8) 8 Percentile of a Distribution The pth percentile ηp is the value such that p% of the observations fall at or below it, i.e., P (X ≤ ηp ) = p% The median is the value such that 50% of the observations fall at or below it. Median is the 50th percentile. Example 12: Suppose that a random variable X follows an exponential distribution with parameter λ = 1. – Find the median of X – Find the 25th percentile 9