You are on page 1of 14

Introduction to Random Variables 1 Definition of random variable

1 Definition of random variable Sometimes, it is not enough to describe all possible results of an
experiment:
2 Discrete and continuous random variable
Toss a coin 3 times: {(HHH), (HHT), …}
Probability function Throw a dice twice: {(1,1), (1,2), (1,3), …}
Distribution function
Some tine it is useful to associate a number to each result of an experiment
Density function
Define a variable
3 Characteristic measures of a random variable
We don’t know the result of the experiment before we carry it out
Mean, variance
We don’t know the value of the variable before the experiment
Other measures

4 Transformation of random variables


1 2
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

1 Definition of random variable 1 Definition of random variable

A random variable is a function which associates a


Sometimes, it is not enough to describe all possible results of an real number to each element of the sample space
experiment:

Toss a coin 3 times: {(HHH), (HHT), …}


Throw a dice twice: {(1,1), (1,2), (1,3), …} Random Variables are represented in capital letters, generally
the last letters of the alphabet: X,Y, Z, etc.
A veces es útil asociar un número a cada resultado del experimento.
X = Number of head on the first toss X[(HHH)]=1, X[(THT)]=0, …
No conocemos el resultado del experimento antes de realizarlo
Y = Sum of points Y[(1,1)]=2, Y[(1,2)]=3, … The values taken by the variable are represented by small letters,
No conocemos el valor que va a tomar la variable antes del experimento
x=1 is a possible value of X
y=3.2 is a possible value of Y
z=-7.3 is a possible value of Z

3 4
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
1 Definition of random variable 1 Definition of random variable

si
Examples
E X(si) = b; si ∈ E
sk

Number of defective units in a random sample of 5 units X(sk) = a


RX
Number of faults per cm2 of material
a b
Lifetime of a lamp

Resistance to compression of concrete • The space RX is the set of ALL possible values of X(s).
• Each possible event of E has an associated value in RX
• We can consider Rx as another random space

5 6
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

1 Definition of random variable Introduction to Random Variables


si
E X(si) = b; si ∈ E
sk 1 Definition of random variable

X(sk) = a 22 Discrete
RX Discrete and
and continuos
continuousrandom
randomvariables
variable
Probability function
a b Distribution function
Density function
The elements in E have a probability distribution, this distribution is also
associated to the values of the variable X. That is, all r.v. preserve the 3 Characteristic measures of a random variable
probability structure of the random experiment that generates it:
Mean, variance
Other measures
Pr( X = x) = Pr( s ∈ E : X ( s ) = x)
4 Transformation of random variables
7 8
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
2 Discrete and continuous random variables 2 Discrete and continuous random variables

Examples
Examplesof
ofdiscrete
discreterandom
randomvariables
variables
The rank of a random variable una variable aleatoria is the set of
possible values taken by the variable. Number
Numberof
offaults
faultson
onaaglass
glasssurface
surface
Depending on the rank, the variables can be classified as: Proportion
Proportionof
ofdefault
defaultparts
partsininaasample
sampleof
of1000
1000
Generally count
Number
Numberof
ofbits
bitstransmited
transmitedand
andreceived
receivedcorrectly
correctly the number of times
Discrete:Those
Discrete: Thosethat
thattake
takeaafinite
finiteor
orinfinite
infinite(numerable)
(numerable)number
numberof
ofvalues
values that something
Examples happens
Examplesof
ofcontinuous
continuous random
randomvariables
variables
Continuous:Those
Continuous: Thosewhose
whoserank
rankisisan
aninterval
intervalof
ofreal
realnumbers
numbers
Electric
Electriccurrent
current

Longitude
Longitude Generally measure a
magnitude
Temperature
Temperature
9 Weight
Weight
10
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

2 Discrete random variables 2 Discrete random variables

The values taken by a random variable change from one experiment


to another, since the results of the experiment are different The properties of the probability function come from the axioms of
probability:
A r.v. is defined by
1. 0≤P(A) ≤1 2. P(E)=1
3. P(AUB)=P(A)+P(B) si A∩B=Ø
The values that it takes. 0 ≤ p ( xi ) ≤ 1
The probability of taking each value. p(xi) n

∑ p( x ) = 1
i =1
i

a < b < c → A = {a ≤ X ≤ b} B = {b < X ≤ c}


Pr(a ≤ X ≤ c) = Pr(a ≤ X ≤ b) + Pr(b < X ≤ c)

This is a function that indicates the probability of each


x
possible value
p ( xi ) = P ( X = xi ) x1 x2 x3 x4 x5 x6 xn

11 12
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
2 Discrete random variables 2 Discrete random variables

Experiment: Toss 2 coins. Experiment: Toss 2 coins.


X=Number of tails. X=Number of tails.

E 0
1/ H H X P(X=x)
TH 4
HH TT 1/
HT 2
Pr 0 1/4
H T
X 1
1 1/2
RX
T H 2 1/4
0 1 2

T T
13 14
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

2 Discrete random variables 2 Discrete random variables

Experiment: Toss 2 coins.


Sometimes we might be interested on the probability that a variable
X=Number of tails. takes a value less or equal to a quantity

p(x) X P(X=x)
0 1/4
F ( x0 ) = P ( X ≤ x0 )
1 1/2 F (−∞) = 0 F (+∞) = 1
if X takes values x1 ≤ x 2 ≤ K ≤ x n :
2 1/4 F ( x1 ) = P( X ≤ x1 ) = p ( x1 )
F ( x2 ) = P( X ≤ x2 ) = p ( x1 ) + p ( x2 )
M
x=0 x=1 x=2 X
F ( xn ) = P( X ≤ xn ) = ∑ i =1 p( xi ) = 1
n

15 16
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
2 Discrete random variables 2 Discrete random variables

Experiment: Toss 2 coins. Experiment: Toss 2 coins.


X=Number of tails. X=Number of tails.

p(x) X P(X=x) F(x) X F(x)


1
0 1/4 0 1/4
0.75
1 1/2 0.5
1 3/4
2 1/4 0.25 2 1
x=0 x=1 x=2 X x=0 x=1 x=2 X

17 18
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

2 Continuous random variables 2 Continuous random variables

When a random variable is continuous, it doesn’t make sense to sum:



Density function describes the probability distribution of a continuous
∑ p( x ) = 1
i =1
i
random variable. It is a function that satisfies:

Since the set of of values taken by the variable is not numerable


f ( x) ≥ 0
We can generalize ∑→ ∫ +∞
∫ −∞
f ( x) dx = 1
We introduce a new concept instead of the probability function of b
discrete random variables P(a ≤ X ≤ b) = ∫ f ( x) dx
a

19 20
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
2 Continuous random variables 2 Continuous random variables

Density function describes the probability distribution of a continuous


random variable. It is a function that satisfies:
a
P( X = a) = ∫ f ( x) dx = 0
a
f ( x) ≥ 0
+∞ P ( a ≤ X ≤ b) = P ( a < X ≤ b)
∫ −∞
f ( x) dx = 1 = P ( a ≤ X < b)
b = P ( a < X < b)
P(a ≤ X ≤ b) = ∫ f ( x) dx
a b a
a
Area below the curve

21 22
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

2 Continuous random variables 2 Continuous random variables

If we measure a continuous variable and represent the values in a


0.5

histogram:
The density function
doesn’t have to be
0.4

symmetric, or be
define for all values fX (x | β )
0.3
x2
0.2
0.1

the form of the


curve will
0.0

depend on one
0 5 10 15 20 25 30
or more
parameters
y
If we make the intervals smaller and smaller:
23 24
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
2 Continuous random variables 2 Continuous random variables

f ( x)

25 26
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

2 Continuous random variables 2 Continuous random variables

Example Example

„ The density function of the use of a machine in a year „ What is the probability that a machine randomly selected has
(in hours x100): been used less than 320 hours?
f(x) f(x)

0.4 P ( X < 3. 2 ) = 0.4


⎧ 0.4
⎪ 2.5 x, 0 < x < 2.5
⎪⎪ 0.4
2. 5
⎛ 0. 4 ⎞ ⎛
3. 2
0. 4 ⎞
f ( x ) = ⎨0.8 − x, 2.5 ≤ x < 5 = ∫⎜ x ⎟dx + ∫ ⎜ 0.8 − x ⎟dx
⎪ 2.5 0⎝
2. 5 ⎠ 2.5⎝
2. 5 ⎠
⎪0, else
elsewhere
⎩⎪ = 0.74
x x
2.5 5 2.5 5
27 3.2 28
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
2 Continuous random variables 2 Continuous random variables

As in the case of discrete random variables, we can define the distribution As in the case of discrete random variables, we can define the distribution
of a continuous random variables by means of the Distribution function: of a continuous random variables by means of the Distribution function:

x x
F ( x) = P( X ≤ x) = ∫ f (u ) du −∞ < x < ∞ F ( x) = P( X ≤ x) = ∫ f (u ) du −∞ < x < ∞
−∞ −∞

In the discrete case, the Probability function is obtained as the


difference of to adjoin values of F(x). In the case of continuous
P( X ≤ x)
variables:
dF ( x)
f ( x) =
dx

x 29 30
Estadística, Profesora: María Durbán

2 Continuous random variables 2 Continuous random variables

The Distribution function satisfies the following properties: The Distribution function satisfies the following properties:

a < b ⇒ F (a ) ≤ F (b) It is non-decreasing a < b ⇒ F (a ) ≤ F (b)


F (−∞) = 0 F (+∞) = 1 It is right-continuous F (−∞) = 0 F (+∞) = 1

−∞
If we define the following disjoint events: F (−∞) = Pr( X ≤ −∞) = ∫ f ( x)dx = 0
−∞
{ X ≤ a} {a < X ≤ b} → { X ≤ a} ∪ {a < X ≤ b} = { X ≤ b} +∞
First axiom of F (+∞) = Pr( X ≤ +∞) = ∫ f ( x)dx = 1
probability −∞
Pr( X ≤ b) = Pr( X ≤ a ) + Pr(a < X ≤ b) ≤ F (b)
≥0
31 32
Third axiom of probability
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
2 Continuous random variables 2 Continuous random variables
Example
Example

The density function of the use of a machine in a year ⎧ 0.4


⎪ 2.5 x, 0 < x < 2.5
„

(en horas x100):



⎪ 0.4
f(x) f ( x) = ⎨0.8 − x, 2.5 ≤ x < 5
⎪ 2.5
0.4 ⎪0, elsewhere
⎧ 0.4 ⎪
⎪ 2.5 x, 0 < x < 2.5 ⎩
Pr(0 < X < 2.5) Pr(2.5 ≤ X < x)
⎪⎪ 0.4 ⎧ x 0.4
f ( x ) = ⎨0.8 − x, 2.5 ≤ x < 5 ⎪ ∫0 u du 0 < x < 2.5
⎪ 2.5 ⎪ 2.5
⎪0, else
elsewhere ⎪ 2.5 0.4 x 0.4
⎪⎩ F ( x) = ⎨ ∫ u du + ∫ 0.8 − u du, 2.5 ≤ x < 5
0 2.5 2.5

2.5

x ⎪
2.5 5 ⎪
33 ⎩1 Pr( X ≤ 5) x≥5 34
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

2 Continuous random variables 2 Continuous random variables


Example
Example Example

P(x<3.2) P(x<3.2)

x=3.2


⎪0.08 x 2 0 < x < 2.5
⎪⎪
F ( x) = ⎨-1 + 0.8 x - 0.08 x 2.5 ≤ x < 5
2



⎪⎩1 x≥5
35 36
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
Introduction to Random Variables 3 Characteristic measures of a r.v.

Central measures

1 Definition of random variable

2 Discrete and continuous random variable In the case of a sample of data, the sample mean allocates a weight of
1/n to each value:
Probability function 1 1 1
x = x1 + x2 + K + xn
Distribution function n n n
Density function
The mean μ or Expectation of a r.v. uses the probability as a weight:
33Characteristic
Characteristicmeasures
measuresofofaarandom
randomvariable
variable
μ = E [ X ] = ∑ xi p( xi ) discrete r.v.
Mean, variance i
Other measures +∞
μ = E [ X ] = ∫ x f ( x) dx continuous r.v.
−∞
4 Transformation of random variables
37 38
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

3 Characteristic measures of a r.v. 3 Characteristic measures of a r.v.

Central measures Example


„ What is the average time of use of the machines?

Intuitively: Median = value that divides the total probability in to parts ⎧ 0.4
⎪ 2.5 x, 0 < x < 2.5

⎪ 0.4
f ( x) = ⎨0.8 − x, 2.5 ≤ x < 5
⎪ 2.5
P( X ≤ m) = 0.5
⎪0, elsewhere


F (m) ≥ 0.5
+∞ 0.4 2 0.4 2
E[X ] = ∫
2.5 5
0.5 0.5 xf ( x)dx = ∫ x dx + ∫ 0.8 x − x dx
−∞ 0 2.5 2.5 2.5
= 2.5
39 40
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
3 Characteristic measures of a r.v. 3 Characteristic measures of a r.v.

Example Other measures

„ If we want to know the time of use such that 50% of the machines
have a use less or equal to that value
The percentil p of a random variable is the value xp that satisfies:
F (m) = 0.5
⎧0.08 x 2 0 < x < 2.5 p( X < x p ) ≤ p y p( X ≤ x p ) ≥ p discrete r.v.

F ( x) = ⎨-1 + 0.8 x - 0.08 x 2 2.5 ≤ x < 5 F (xp ) = p continuous r.v.
⎪1 x≥5

A special case are quartiles which divide the distribution in 4 parts
0.08 x 2 = 0.5 → m = 2.5
-1 + 0.8 x - 0.08 x 2 = 0.5 → m = 2.5 Q1 = p0.25
Q2 = p0.5 = Median
Q3 = p0.75
41 42
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

3 Characteristic measures of a r.v. 3 Characteristic measures of a r.v.

Medisures of dispersion Medisures of dispersion

Var [ X ] = E ⎡( X − E [ X ]) ⎤ Var [ X ] = E ⎡( X − E [ X ]) ⎤
2 2

⎣ ⎦ ⎣ ⎦
The sample variance of a set of data is given by:
1 1 1
Var [ X ] = E ⎡⎣ X 2 ⎤⎦ − ( E [ X ])
2
s2 = (x1 −x)2 + (x2 −x)2 +K+ (xn −x)2
n n n
The Variance of a r.v. also uses the probability as a weight:
E ⎡( X − E [ X ]) ⎤ = E ⎡ X 2 + ( E [ X ]) − 2 XE [ X ]⎤
2 2

⎣ ⎦ ⎣ ⎦
= E ⎡⎣ X 2 ⎤⎦ + ( E [ X ]) − 2 E [ X ] E [ X ] E [ X ] is a constant,
2

σ = Var [ X ] = ∑ ( xi − μ ) p( xi )
2 2
discrete r.v. does not depend on X
= E ⎡⎣ X 2 ⎤⎦ − ( E [ X ])
2
i It is a linear operator
+∞
σ 2 = Var [ X ] = ∫ ( x − μ ) 2 f ( x) dx continuous r.v. 43 44
Estadística, Profesora: María Durbán −∞ Estadística, Profesora: María Durbán
Introduction to Random Variables 4 Transformation of random variables

In some situations we will need to know the probability distribution of a


1 Definition of random variable transformation of a random variable

2 Discrete and continuous random variable Examples


Probability function Change units
Distribution function Use logarithmic scale
Density function
aX + b
3 Characteristic measures of a random variable sin
sinXX X2

Mean, variance 11
Y = g( X ) |X |
Other measures XX
X
4 Transformation
4 Transformation of of random
random variables
variables log X X
45
e 46
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

4 Transformation of random variables 4 Transformation of random variables

Let X be a r.v. If we change to Y=h(X), we obtain a new r.v.: Example


A company packs microchips in lots. It is know that the probability
distribution of the number of microchips per lots is given by:
Distribution function
x p(x) F(x)
Y = h( X ) 11 0.03 0.03 ¿ Pr( X 2 ≤ 144)? {
A = x, x ≤ 144 }
12 0.03 0.06
13 0.03 0.09
Pr( X 2 ≤ 144) = Pr( x ∈ A) A = { x, x 2 ≤ 144}
FY ( y ) = Pr(Y ≤ y ) = Pr(h( X ) ≤ y ) = Pr( x ∈ A) 14 0.06 0.15
15 0.26 0.41 Pr ( X ≤ 12 ) = 0.06
16 0.09 0.5
A = { x, h( x) ≤ y} 17 0.12 0.62
18 0.21 0.83
19 0.14 0.97
47 20 0.03 1 48
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
4 Transformation of random variables 4 Transformation of random variables
Density function
Y = h( X )
If X is a continuous r.v. Y=h(X), where h is derivable and inyective
In general:

If h is continuous and monotonic increasing : dx


fY ( y ) = f X ( x )
dy
FY ( y ) = Pr(h( X ) ≤ y ) = Pr( X ≤ h −1 ( y )) = FX (h −1 ( y ))

If h is continuous and monotonic decreasing: x


⎧ ∂FX ( x) dx
increasing
FY ( y ) = Pr(h( X ) ≤ y ) = Pr( X ≥ h ( y )) = 1 − FX (h ( y ))−1 −1 ∂FY ( y ) ∂Fx (h ( y )) ⎪⎪ −1
dx dy
fY ( y ) = = =⎨
∂y ∂y ⎪ ∂ (1 − FX ( x)) dx
decreasing
⎪⎩ dx dy
49 50
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

4 Transformation of random variables 4 Transformation of random variables

Example
If X is a continuous r.v. Y=h(X), where h is derivable and inyective
The velocity of a gas particle is a r.v. V with density function

dx
fY ( y ) = f X ( x ) (b 2 / 2)v 2 e − bv v > 0
dy fV (v) =
0 elsewhere

For discrete r.v.: The kinetic energy of the particle is W = mV 2 / 2 What is the density
function of W?

pY ( y ) = Pr(Y = y ) = ∑
h ( xi ) = y
Pr( X = xi )

51 52
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán
4 Transformation of random variables 4 Transformation of random variables

Example Example

The velocity of a gas particle is a r.v. V with density function The velocity of a gas particle is a r.v. V with density function

(b 2 / 2)v 2 e − bv v > 0 (b 2 / 2)v 2 e − bv v > 0


fV (v) = fV (v) =
0 elsewhere 0 elsewhere

W = mV 2 / 2 → v = 2w / m v = − 2w / m
(b 2 / 2m) 2w / m e − b 2 w / m w > 0
fW ( w) =
( )e
dv 1
=
2
fV (h −1 ( w)) = (b 2 / 2) 2w / m −b 2 w / m
0 elsewhere
dw 2mw
53 54
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

4 Transformation of random variables 4 Transformation of random variables

Expectation Expectation

+∞ +∞

E [ h( X ) ] =
∫ −∞
h( x) f X ( x)dx
E [ h( X ) ] =
∫ −∞
h( x) f X ( x)dx

∑ h( xi ) p ( X = xi ) ∑ h( xi ) p ( X = xi )
Y = h( X ) xi , h ( xi ) = y xi , h ( xi ) = y

increasing
Linear Transformations
+∞ +∞ dx
E [ y] = ∫ yf y ( y )dy = ∫ h( x) f X ( x) dy
−∞ −∞ dy Y = a + bX

E [Y ] = a + bE [ X ]
Var [Y ] = b 2Var [ X ]
55 56
Estadística, Profesora: María Durbán Estadística, Profesora: María Durbán

You might also like