Random variable

advertisement
Lecture 5 - Random variables
Learning Objectives
• After completing this lecture, the students should be
able to define and work with
– Random variables (Discrete and Continuous).
– Probability mass functions and density functions.
– Cumulative distribution functions.
– Expectations and variances of random variables.
STAT 101
1
Random variables
Random variable
Let S be a sample space corresponding to the random
experiment E. A function X defined on the sample space S
to the real number system R is called a random variable.
R
S
s
X(s)=x
• Note that random variables are written by uppercase
letters.
• The values taken by the random variables are written
by the corresponding lowercase letters..
STAT 101
2
Random variables
Example 5.1
• E – Tossing a fair coin twice and let X be the number of
heads obtained.
• The sample space S = {TT, TH, HT, HH}
X (TT )  0, X (TH )  X ( HT )  1 and X ( HH )  2
• The Set R = {0,1, 2} is called the range space of X.
Discrete Random Variable
• Assumes a finite or countably infinite number of values.
• The values can be enumerated and listed as
x1 , x2 ,.....,xn ,....
STAT 101
3
Random variables
Continuous Random variables
• Assumes uncountable number of values from a region.
Examples
• X= Height of an individual in our class (Continuous random
variable).
• X = Number of Female students in our class ( Discrete
random variable)
• X = Number of tosses required of a coin to obtain Head for
the fifth time. (Discrete random variable)
STAT 101
4
Random variables
Probability mass function
• Let X be a discrete random variable with range space
R {x1 , x2 ,......,xn ,....}.
• With each value of X we assign a nonnegative real number
satisfying the following conditions
(a) p( xi )  0 and
x1
x2 ........xn .........
px1 
px2 ...pxn .......

(b) p( xi )  1
1
• The assignment xi , p( xi ) i 1, 2,...n is called the probability
mass function of X.
STAT 101
5
Lecture 4 - Random variables
Example 5.2
• Let X be the number of heads obtained. The range space of
X is RX  0, 1, 2.
• We assign the a nonnegative mass with each value as
shown
P( X  0) 
1
4
P( X  1) 
2
4
P( X  2) 
1
4
• The assignment is a valid probability assignment and hence
is known as probability mass function of X.
P(x) 1/2
1/4
0
1
2
STAT 101
x
6
Random variables
• To find the probability of an event A, we add the
probabilities attached to the elements of the event.
P( A)   P( x)
xA
• For example,
P ( X  1)  P ( X  1)  P ( X  2)
1 1
3
  
2 4
4
STAT 101
7
Random variables
Probability density function (pdf)
A function f (x) can be a probability density function of a
continuous random variable X if it satisfies the following
conditions
(a) f ( x)  0 for all x

(b)
 f ( x) dx  1

Note that f ( x ) at any specific point x0 has no meaning.
• To find the probability of an event, we integrate the density
function over the event. That is,
0
b
P(a  X  b)   f ( x) dx
a
STAT 101
8
Random variables
Example 5.3
Consider the function
2 x, 0  x  1
f ( x)  
0, elsewhere
Since, 0  x  1, f ( x)  0 for all x.
1

0
1
x2
f ( x) dx   2 x dx  2
2
0
1
0
 1 0  1
The function
To find
f (x)
is a valid pdf.
1
x2
P(0.5  X  1)   2 x dx  2
2
0.5
1
 1
0.5
STAT 101
1 3

4 4
9
Random variables
Cumulative Distribution Function (CDF)
The cumulative distribution function of a random variable X is
defined as
F ( x )  P( X  x )
• For a discrete random variable
F ( x) 
 P( x )

x
X x
X x
• For a continuous random variable
x
F ( x) 
 f ( x)dx

STAT 101
10
Random variables
Example 5.4
• Consider the prob. distribution in example 4.2.
P( X  0) 
1
4
P( X  1) 
2
4
P( X  2) 
1
4
P(x) 1/2
F (x)
1
1/4
p ( 2)
3/4
p(1)
0
1
2
1/4
x
p (0)
0
0 if x  0
0.25 if 0  x  1

F ( x)  
0.75 if 1  x  2

if x  1
1
• The CDF is
STAT 101
1
x
2
Properties of F(x) ?
11
Random variables
Example 5.5
Consider the density function
f (x)
0
1
2 x, 0  x  1
f ( x)  
0, elsewhere
x
The cumulative distribution function
F (x)
0 if x  0
x

F ( x)   2 x dx  x 2 if 0  x  1
0
1
if x  1

1
x2
0
STAT 101
1
12
Random variables
Properties
(a) The CDF of a continuous random variable is a continuous
function.
(b) Non decreasing function
(c) F ()  0 and F ()  1
(d) The pdf f ( x) 
d
F ( x ) 
dx
STAT 101
13
Random variables
Characteristics of a random variables
Expected value of a random variable
Let X be a discrete random variable with known probability
distribution p(x). The expected value of X is defined as

E ( X )   xi p( xi )
1
• E(X) is a weighted average of all possible values of X.
• E(X) is a population mean and we denote it by  X
• For a continuous random variable with pdf f(x),

E( X ) 
 x f ( x) dx

STAT 101
14
Random variables
Properties
(a) E(c) = c, where c is a constant.
(b) E(a + b X) = a + b E(X), where a and b are constants.
(c) E (X + Y ) = E (X) + E ( Y)
(d) E ( XY ) = E(X) E(Y) only if X and Y are independent
(discussed in lecture 6)
(e) Let X be a random variable and let Y = g(X), then

E (Y )   g ( xi ) p( xi ) (discrete)
1
STAT 101

E (Y ) 
 g ( x)
f ( x) dx

15
Random variables
Example 5.6
The probability distribution of daily demand for a product is
d
p(d)
1
2
3
4
5
0.1
0.1
0.3
0.3
0.2
Evaluate E(D).
Solution
BY definition
5
E ( D)   d i p ( d i )
1
 1(0.1)  2(0.1)  3(0.3)  4(0.3)  5(0.2)
 0.1  0.2  0.9  1.2  1.0  3.4
STAT 101
16
Random variables
Variance
• measures the spread of values of X around its mean value.
• measured in the squared units of measurement for X.
• defined as
V ( X )   X2  E{X  E( X )}2
• The positive square root of V(X) is called the standard
deviation of X and is denoted by  X
• Variance  X2  E{ X  E ( X )}2
 E{ X 2  E  X   2 XE( X )
2
 
 E X 2  E  X   2E  X 
2
 
2
V ( X )  E X 2  E  X 
STAT 101
2
17
Random variables
Properties
(a) V (c) = 0, where c is a constant.
(b) V(X + c) = V(X)
2
(c) V(c X) = c V ( X )
(d) If X and Y are independent, then V(X + Y) = V(X) + V(Y)
STAT 101
18
Random variables
Example 5.7
24
Suppose that X has pdf f ( x)  4 , x  2. Evaluate the variance
x
of X.
Solution
By definition

E ( X )   x f ( x) dx
2

 x
2

24
1
3
dx

24
x
dx

24

2
x4
2x2
STAT 101

3
2
19
Random variables
Example 5.7

E ( X 2 )   x 2 f ( x) dx
2

  x2
2


24
1
2
dx

24
x
dx

24

2
x4
x


 12
2
V ( X )  E X 2  EX 
2
 12  32  3
STAT 101
20
Download