42
3-1 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01 3 - Random Variables Estimation Example: radar Example: communication channel Example: force on mass Events corresponding to random variables Induced probability Functions of a random variable Cumulative distribution Simulation of random variables Expectation The vector space of random variables Variance and its interpretation The mean-variance decomposition

3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

3 - Random Variables

• Estimation

• Example: radar

• Example: communication channel

• Example: force on mass

• Events corresponding to random variables

• Induced probability

• Functions of a random variable

• Cumulative distribution

• Simulation of random variables

• Expectation

• The vector space of random variables

• Variance and its interpretation

• The mean-variance decomposition

Page 2: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 2 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Random variables

Suppose Ω is a finite sample space, with pmf p

A function x : Ω → V is called a random variable.

• The set V can be any set; it is the set of values of x.

• Often V is Rn or just R; then x is called a random vector

Page 3: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 3 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Random variables and models

We model systems using random variables.

• Ω is a sample space. Exactly one outcome ω ∈ Ω occurs.

• We have a measurement random vector y : Ω → Rn.

• We have a hypothesis random vector x : Ω → Rn

Estimation

• We measure y(ω)

• We would like to estimate x(ω)

Page 4: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

0 1

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

3 - 4 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: radar system

A radar system sends out n pulses, and receives y reflections, where 0 ≤ y ≤ n.

Ideally, y = n if an aircraft is present, and y = 0 otherwise.

In practice, reflections may be lost, or noise may be mistaken for reflections.

The set of outcomes is

Ω =

(x, y) | x ∈ 0, 1 and y ∈ 0, 1, . . . , n

Here

• x = 1 if an aircraft is present, x = 0 otherwise

• y is the number of reflection pulses received

We measure y, and would like to determine x.

Page 5: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

0 1 2 3 4 5 6 7

0

1

2

3

4

5

6

7

3 - 5 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: communication channel

• A symbol x ∈ 0, 1, . . . , n − 1 is sent.

• The channel is noisy, so the symbol receivedmay not match what is sent.

• The symbol y ∈ 0, 1, . . . , n−1 is received.

The set of outcomes is

Ω =

(x, y)∣

∣ x ∈ 0, 1, . . . , n − 1 and y ∈ 0, 1, . . . , n − 1

We measure y, and would like to determine x.

Page 6: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 6 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: force on mass

Mass acted on by forces

• known sequence of forces u1, u2, . . . , un

• additional random force disturbance r1, r2, . . . , rn

• we make a noisy measurement y = v + position at time n/2

where v is random noise

• we’d like to estimate or predict the position x at time n

The set of outcomes is Ω = Rn+1, where ω =

[

vr

]

We have linear equations

y = A(u + r) + v

x = P (u + r)

Page 7: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 7 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Estimation

We would like to design estimators.

Performance measures include

• the probability that the estimate is correct

• the mean size of the error, in some sense

• the bias of the estimator

• continuous problems: are estimates on average too low or too high?

• discrete problems: what are the probabilities of false positives or false negatives?

Page 8: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 8 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Random variables

We have

• sample space Ω, a finite set

• probability mass function p : Ω → [0, 1]

• a random variable x : Ω → R

Suppose a ∈ R. The probability that x = a is defined as

Prob

(

ω ∈ Ω | x(ω) = a

)

This is equal to∑

ω∈Ω | x(ω)=a

p(ω)

Page 9: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

1 2 3 4 5 6

1

2

3

4

5

6

3 - 9 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: two dice

We have sample space

Ω =

(ω1, ω2) ∈ Ω | ωi ∈ 1, 2, . . . , 6

Define the random variable x : Ω → R, the sum of the two dice by

x(ω1, ω2) = ω1 + ω2

Then Prob(x = 5) = Prob(A) where theevent A is

A =

ω ∈ Ω | x(ω) = 5

Page 10: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

1 2 3 4 50

0.1

0.2

0.3

0.4

p(ω)

ω

−1 1 20

0.1

0.2

0.3

0.4

Prob(x = a)

a

3 - 10 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Probability and random variables

The probability of the event that x = a is written Prob(x = a), i.e.,

Prob(x = a) = Prob

(

ω ∈ Ω | x(ω) = a

)

Suppose Ω = 1, 2, 3, 4, 5 and p is as shown

The random variable x : Ω → R is

x(ω) =

−1 if ω = 1 or ω = 2

1 if ω = 3 or ω = 4

2 if ω = 5

and Prob(x = a) is shown.

Page 11: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 11 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Notations used for random variables

• The event that x = a is written

x−1(a) =

ω ∈ Ω | x(ω) = a

• The probability of this event is written as Prob(x = a)

• This is also written px(a) = Prob(x = a)

Page 12: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 12 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Notation for random variables

There are many similar notations used: for example, define

• Prob(x = a) = Prob(

x−1(a))

• Prob(x ≥ a) = Prob(

ω ∈ Ω | x(ω) ≥ a)

• If C ⊂ V , then Prob(x ∈ C) = Prob(

ω ∈ Ω | x(ω) ∈ C)

Page 13: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 13 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Events corresponding to random variables

Suppose x : Ω → V . Each a ∈ V defines an event

x−1(a) =

ω ∈ Ω | x(ω) = a

These events partition Ω

For example, if Ω = 1, 2, 3, 4, 5 and the random variable x is

x(ω) =

−1 if ω = 1 or ω = 2

1 if ω = 3 or ω = 4

2 if ω = 5

The events associated with x are

x−1(−1) = 1, 2 x−1(1) = 3, 4 x−1(2) = 5

Page 14: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 14 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: sum of two dice

The events are

1 2 3 4 5 6

1

2

3

4

5

6

Page 15: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 15 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Induced probability

Suppose x : Ω → V . The induced pmf of x is the function px : V → [0, 1]

px(a) = Prob(x = a)

It satisfies the properties of a probability mass function

• px(a) ≥ 0 for all a ∈ V

•∑

a∈V

px(a) = 1

because the events x−1(a) partition Ω, so

a∈V

px(a) =∑

a∈V

Prob(

x−1(a))

= 1

Page 16: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 16 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: sum of two dice

The induced pdf is below

1 2 3 4 5 6

1

2

3

4

5

6

2 4 6 8 10 120

0.05

0.1

0.15

0.2

px(a)

a

Page 17: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 17 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Random variables

Another name for a random variable is a change of variables

1 2 3 4 5 6

1

2

3

4

5

6 V, px

Ω, p

x−→

The map x induces the pmf px on V

Page 18: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 18 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: sum of two dice

So there are two ways to compute, for example, Prob(x = 4 or x = 5)

• There are seven corresponding outcomes ω in Ω, each with probability 1/36.

Prob(x = 4 or x = 5) = Prob

(

ω ∈ Ω | x(ω) = 4 or x(ω) = 5

)

• Or alternatively: Prob(x = 4 or x = 5) = px(4) + px(5)

1 2 3 4 5 6

1

2

3

4

5

6

V, pxΩ, px

−→

Page 19: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 19 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: sum of two dice

Another example: suppose we want to compute

Prob(

(x − 6)2 = 16)

• By definition

Prob(

(x − 6)2 = 16)

= Prob

(

ω ∈ Ω |(

x(ω) − 6)2

= 16

)

• Or using the induced pmf

Prob(

(x − 6)2 = 16)

=∑

a∈C

px(a)

whereC =

a ∈ V | (a − 6)2 = 16

Page 20: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 20 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: sum of two dice

We can also do this another way: let f : R → R be

f (x) = (x − 6)2

and define the random variable y = f (x), which means y(ω) = f (x(ω))

ThenProb(y = 16) = py(16)

1 2 3 4 5 6

1

2

3

4

5

6 V, px

Ω, p

U, py

x−→

f−→

Page 21: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

1 2 3 4 50

0.1

0.2

0.3

0.4

p(ω)

ω

−1 1 20

0.1

0.2

0.3

0.4

px(a)

a

1 40

0.1

0.2

0.3

0.4

0.5

0.6

0.7

py(b)

b

3 - 21 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: functions of a random variable

• Suppose Ω = 1, 2, 3, 4, 5 and p is as shown

• The random variable x : Ω → R is

x(ω) =

−1 if ω = 1 or ω = 2

1 if ω = 3 or ω = 4

2 if ω = 5

• The random variable y = x2, meaning

y(ω) = x(ω)2 for all ω ∈ Ω

Page 22: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 22 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Functions of a random variable

• x is a random variable x : Ω → V

• y is a function of x, that is f : V → U and y = f (x)

Then y defines a random variable y(ω) = f(

x(ω))

. The induced pmf of y is

py(b) =∑

a∈V | y(a)=b

px(a)

Page 23: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 23 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Functions of a random variable

Because

py(b) =∑

ω∈Ω | y(x(w))=b

p(ω)

=∑

a∈V | y(a)=b

ω∈Ω |x(ω)=a

p(ω)

=∑

a∈V | y(a)=b

px(a)

V, px

Ω, p

U, py

x−→

f−→

Page 24: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 24 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Induced sample spaces

We’ve seen two ways to compute Prob(y = b)

• As a sum over the sample space Ω

Prob(y = b) =∑

ω∈Ω | y(x(w))=b

p(ω)

• As a sum over the set V

Prob(y = b) =∑

a∈V | y(a)=b

px(a)

Hence we can think of V as a new sample space, called the induced sample space, withpmf px : V → [0, 1]

We can compute probabilities of functions of x without knowing the original sample spaceΩ and the pmf p.

Page 25: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

0 1 2 3 4 50

0.2

0.4

0.6

0.8

1

F (a)

a

3 - 25 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

The cumulative distribution

Suppose x : Ω → R is a real-valued random variable; for example

0 1 2 3 4 50

0.1

0.2

0.3

0.4

px(a)

a

The cumulative distribution (cdf) of x is a function F : R → R given by

F (a) = Prob(x ≤ a)

• F is piecewise constant

• F is right continuous

Page 26: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 26 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

The uniform random variable

In many codes, one has access to a uniform random number generator.

The key property is, for 0 ≤ a ≤ b ≤ 1

Prob(u ∈ [a, b]) = b − a

• In Matlab this is u=rand; not randn.

• More on continuous random variables later. . .

Page 27: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 27 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Simulation of random variables

Suppose x : Ω → R is a random variable with cdf F

Define the function g : R → R as below (it’s almost the inverse of F )

0 1 2 3 4 50

0.2

0.4

0.6

0.8

1

F (a)

a0 0.2 0.4 0.6 0.8 1

0

1

2

3

4

5

g(b)

b

If u is uniform, then

Prob(

g(u) = a)

= Prob(x = a)

and so one can simulate x by setting x = g(u).

Page 28: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 28 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Expectation

Suppose x : Ω → R is a real-valued random variable. The expectation of x is

E x =∑

ω∈Ω

x(ω)p(ω)

• Also called the mean of x or the expected value of x

Page 29: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

1 2 3 4 50

0.1

0.2

0.3

0.4

p(ω)

ω

3 - 29 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: expectation

Suppose Ω = 1, 2, 3, 4, 5, and p is plotted

Let random variable x : Ω → R be

x(a) =

−1 if a = 1 or a = 2

1 if a = 3 or a = 4

2 if a = 5

The expectation is E x = −0.1 − 0.15 + 0.1 + 0.25 + 2(0.4) = 0.9

Page 30: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 30 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Vector spaces

The set of real-valued random variables is a vector space.

Because if x and y are two random variables, so is λx + µy.

• Suppose Ω =

ω1, ω2, . . . , ωn

• Suppose x : Ω → R is a random variable.

• Define the vector r ∈ Rn by

ri = x(ωi) for all i = 1, . . . , n

Usually we abuse notation and use x to denote both the vector r ∈ Rn and the random

variable x : Ω → R.

Page 31: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 31 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Vector spaces

We can also represent the pmf p : Ω → [0, 1] by a vector.

Define the vector p ∈ Rn (again abusing notation) by

pi = p(ωi) for all i = 1, . . . , n

• The vector p defines a pmf if and only if 1Tp = 1 and p º 0, where

• p º 0 means pi ≥ 0 for all i = 1, . . . , n

• 1 is the vector of all ones

• A vector p satisfying these conditions is called a distribution vector

Page 32: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 32 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Expectation and vector representations

It’s easy to compute the expected value of the random variable x.

E x = pTx

Because

E x =∑

ω∈Ω

x(ω)p(ω)

=

n∑

i=1

xipi

Hence expectation is linear

E(αx + βy) = αE x + β E y

Page 33: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

1 2 3 4 50

0.1

0.2

0.3

0.4

p(ω)

ω

3 - 33 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: expectation

Suppose Ω = 1, 2, 3, 4, 5, and p is plotted

The random variable x =

−1−1

112

and p =

0.10.150.10.250.4

The expectation is E x = pTx = −0.1 − 0.15 + 0.1 + 0.25 + 2(0.4) = 0.9

Page 34: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

−1 1 20

0.1

0.2

0.3

0.4

px(a)

a

3 - 34 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Another way to compute expectation

Suppose x : Ω → V and V ⊂ R. The expectation of x is also given by

E x =∑

a∈V

apx(a)

e.g., the random variable x : Ω → R hasinduced pmf as shown.

So the expectation isE x = −0.25 + 0.35 + 2(0.4) = 0.9

Page 35: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 35 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Another way to compute expectation

Because∑

ω∈Ω

x(ω)p(ω) =∑

a∈V

ω∈Ω, x(ω)=a

x(ω)p(ω)

=∑

a∈V

a∑

ω∈Ω, x(ω)=a

p(ω)

=∑

a∈V

apx(a)

Again there are two ways to compute

• summing over Ω

E x =∑

ω∈Ω

x(ω)p(ω)

• summing over V

E x =∑

a∈V

apx(a)

Page 36: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 36 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Interpreting the mean

The mean is

E x =∑

a∈R

apx(a)

• We interpret the mean as the center of mass of the distribution

• The plot below shows the induced pmf of x

0 2 4 6 80

0.05

0.1

0.15

0.2

0.25

px(a)

a

Page 37: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 37 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Variance

Suppose x : Ω → R is a random variable. The covariance of x is

cov(x) = E

(

(x − E x)2)

• Measures the mean square deviation from the mean

• Another common notation: the standard deviation is

std(x) =√

cov(x)

• The covariance is also called the variance

Page 38: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 38 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Intepreting the covariance

The following are the induced pmfs of two random variables

0 10 20 300

0.05

0.1

0.15

px(a)

a0 10 20 30

0

0.05

0.1

0.15

py(b)

b

Standard deviations are std(x) = 3.5 and std(y) = 6.5.

• The covariance gives a measure of how wide the range of values of a random variableextends around the mean.

• A small covariance means that the pmf is concentrated around the mean

Page 39: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 39 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Variance

We have the variance is

cov(x) = E

(

(x − E x)2)

What this means is:

• Let µ ∈ R be the expected value of x; i.e., µ = E x.

• Define a new random variable y : Ω → R by

y(ω) = (x(ω) − µ)2 for all ω ∈ Ω

• Then cov(x) = E y

• Several ways to compute this: by summing over Ω, or summing over the values of x,or summing over the values of y

Page 40: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 40 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Example: variance

Suppose Ω = 1, 2, 3, 4, 5 and p is below.

0 1 2 3 4 5 60

0.1

0.2p(ω)

ω

The random variable x is x(ω) =

3 if ω = 1 or ω = 2

4 if ω = 3

6 if ω = 4 or ω = 5

Hence E x = 4, and the random variable y = (x − Ex)2 is

y(ω) =

(3 − 4)2 if ω = 1 or ω = 2

(4 − 4)2 if ω = 3

(6 − 4)2 if ω = 4 or ω = 5

Hence cov(x) = E(y) = 1.5

Page 41: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 41 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Mean-variance decomposition

The mean square of x is E(x2). We have

E(x2) = (E x)2 + cov(x)

Called the mean-variance decomposition.

Easy to see; for convenience let µ = E x. Then

cov(x) = E(

(x − µ)2)

= E(

x2 − 2µx + µ2)

= E(

x2)

− 2µE x + µ2

= E(

x2)

− µ2

Page 42: 3 - 1 Probability on Finite Sets S. Lall, Stanford 2011.01 ...engr207b.stanford.edu/lectures/random_variables_2011_01_04_01.pdf · 14 15 3 - 4 Probability on Finite Sets S. Lall,

3 - 42 Probability on Finite Sets S. Lall, Stanford 2011.01.04.01

Moments of a random variable

Suppose x : Ω → R is a random variable. The n’th moment of x is

E(xn) =∑

ω∈Ω

x(ω)np(ω)

• The mean Ex is the first moment of x

• The covariance is the second moment minus the square of the first moment.