Tutorial 2 the outline Example-1 from linear algebra Conditional - - PowerPoint PPT Presentation

tutorial 2 the outline
SMART_READER_LITE
LIVE PREVIEW

Tutorial 2 the outline Example-1 from linear algebra Conditional - - PowerPoint PPT Presentation

Tutorial 2 the outline Example-1 from linear algebra Conditional probability Example 2: Bernoulli Distribution Bayes' Rule Example 3 Example 4 The game of three doors 236607 Visual Recognition Tutorial 1 Example 1: Linear Algebra A


slide-1
SLIDE 1

236607 Visual Recognition Tutorial 1

Example-1 from linear algebra Conditional probability Example 2: Bernoulli Distribution Bayes' Rule Example 3 Example 4 The game of three doors

Tutorial 2 – the outline

slide-2
SLIDE 2

236607 Visual Recognition Tutorial 2

A line can be written as ax+by=1. You are given a number

  • f example points:

Let

  • (A) Write a single matrix equation that expresses the

constraint that each of these points lies on a single line

  • (B) Is it always the case that some M exists?
  • (C) Write an expression for M assuming it does exist.

1 1 n n

Example – 1: Linear Algebra

x y P x y ⎡ ⎤ ⎢ ⎥ = ⎢ ⎥ ⎢ ⎥ ⎣ ⎦ M M a M b ⎡ ⎤ = ⎢ ⎥ ⎣ ⎦

slide-3
SLIDE 3

236607 Visual Recognition Tutorial 3

(A) For all the points to lie on the line, a and b must satisfy the following set of simultaneous equations: ax1+by1=1 : axN+byN=1 This can be written much more compactly in the matrix form (linear regression equation): PM=1 where 1 is an Nx1 column vector of 1’s. (B) An M satisfying the matrix equation in part (A) will not exist unless al the points are collinear (i.e. fall on the same line). In general, three or more points may not be collinear. (C) If M exists, then we can find it by finding the left inverse of P, but since P is in general not a square matrix P -1 may not exist, so we need the pseudo-inverse (P TP) -1 P T. Thus M= (P TP) -1 P T 1.

Example – 1: Linear Algebra

slide-4
SLIDE 4

236607 Visual Recognition Tutorial 4

When 2 variables are statistically dependent, knowing the value of one of them lets us get a better estimate of the value

  • f the other one. This is expressed by the conditional

probability of x given y: If x and y are statistically independent, then

Conditional probability

Pr{ , } ( , ) Pr{ | } , or ( | ) Pr{ } ( )

i j i j j y

x v y w P x y x v y w P x y y w P y = = = = = = = ( | ) ( ).

x

P x y P x =

slide-5
SLIDE 5

236607 Visual Recognition Tutorial 5

Bayes' Rule

  • The law of total probability: If event A can occur in m

different ways A1,A2,…,Am and if they are mutually exclusive,then the probability of A occurring is the sum of the probabilities A1,A2,…,Am . From definition of condition probability ( ) ( , ).

x

P y P x y

χ ∈

= ∑

( , ) ( | ) ( ) ( | ) ( ) Px y Px y P y P y x Px = =

slide-6
SLIDE 6

236607 Visual Recognition Tutorial 6

Bayes' Rule

  • r

( | ) ( ) ( | ) ( ) ( | ) ( , ) ( | ) ( )

x x

P y x P x P y x P x P x y P x y P y x P x

χ χ ∈ ∈

= =

∑ ∑

likelihood prior posterior evidence × =

( | ) ( ) ( | ) ( )

x

P y x P x P x y P y =

slide-7
SLIDE 7

236607 Visual Recognition Tutorial 7

  • For continuous random variable we refer to densities rather

than probabilities; in particular,

  • The Bayes’ rule for densities becomes:

Bayes' rule – continuous case

( , ) ( | ) ( ) p x y p x y p y =

( | ) ( ) ( | ) ( | ) ( ) p y x p x p x y p y x p x dx

∞ −∞

=

slide-8
SLIDE 8

236607 Visual Recognition Tutorial 8

Call x a ‘cause’, y an effect. Assuming x is present, we know the likelihood of y to be observed The Bayes’ rule allows to determine the likelihood of a cause x given an observation y. (Note that there may be many causes producing y ). The Bayes’ rule shows how probability for x changes from prior p(x) before we observe anything, to posterior p(x| y)

  • nce we have observed y.

Bayes' formula - importance

slide-9
SLIDE 9

236607 Visual Recognition Tutorial 9

A random variable X has a Bernoulli distribution with parameter θ if it can assume a value of 1 with a probability of θ and the value of 0 with a probability of (1-θ ). The random variable X is also known as a Bernoulli variable with parameter θ and has the following probability mass function: The mean of a random variable X that has a Bernoulli distribution with parameter p is E(X) = 1(θ) + 0(1- θ) = θ The variance of X is ( , ) 1 x x x θ θ θ

Example – 2: Bernoulli Distribution

=1 ⎧ = ⎨ − = 0 ⎩ p

slide-10
SLIDE 10

236607 Visual Recognition Tutorial 10

A random variable whose value represents the outcome of a coin toss (1 for heads, 0 for tails, or vice-versa) is a Bernoulli variable with parameter θ, where θ is the probability that the outcome corresponding to the value 1 occurs. For an unbiased coin, where heads or tails are equally likely to occur, θ = 0.5. For Bernoulli rand. variable xn the probability mass function is: For N independent Bernoulli trials we have random sample

2 2 2 2 2 2

( ) ( ) [ ( )] 1 ( ) 0 (1 ) (1 ) Var X E X E X

Example – 2: Bernoulli Distribution

θ θ θ θ θ θ θ = − = + − − = − = −

1

( | ) ( ) (1 ) ,

n n

x x n n n

P x P x x

θ

θ θ θ

= = − = 0,1

1 1

( , ,..., )

N

x x x

= x

slide-11
SLIDE 11

236607 Visual Recognition Tutorial 11

The distribution of the random sample is: The distribution of the number of ones in N independent Bernoulli trials is: The joint probability to observe the sample x and the number k

( ) (1 )

k N k

N P k k

θ

θ θ

Example – 2: Bernoulli Distribution

⎛ ⎞ = − ⎜ ⎟ ⎝ ⎠

1 1

( ) (1 ) (1 )

n n

N x x k N k n

P

θ

θ θ θ θ

− − − =

= − = −

x

1 1 1

number of ones ( , ,..., ).

N n N n

k x x x x x

− − =

= ∈ =

( ), number of ones ( , ) 0,

  • therwise

P k P k

θ θ

= ∈ ⎧ = ⎨ ⎩ x x x

slide-12
SLIDE 12

236607 Visual Recognition Tutorial 12

The conditional probability of x given the number k of ones: Thus

Example – 2: Bernoulli Distribution

( , ) (1 ) 1 ( | ) ( ) (1 )

k N k k N k

P k P k N N P k k k

θ θ θ

θ θ θ θ

− −

− = = = ⎛ ⎞ ⎛ ⎞ − ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ ⎝ ⎠ x x 1 ( ) ( | ) ( ) ( ) P P k P k P k N k

θ θ θ θ

= = ⎛ ⎞ ⎜ ⎟ ⎝ ⎠ x x

slide-13
SLIDE 13

236607 Visual Recognition Tutorial 13

Assume that X is distributed according to the Gaussian density with mean μ=0 and variance σ 2=1.

  • (A) What is the probability that x =0 ?

Assume that Y is distributed according to the Gaussian density with mean μ=1 and variance σ2=1.

  • (B) What is the probability that y =0 ?

Given a distribution: Pr(Z=z)=1/2Pr(X=z)+1/2Pr(Y=z) known as a mixture (i.e. ½ of the time points are generated by the X process and ½ of the time points by the Y process ).

  • (C) If Z =0, what is the probability that the X process generated this

data point ?

Example - 3

slide-14
SLIDE 14

236607 Visual Recognition Tutorial 14

(A) Since p(x) is a continuous density, the probability that x=0

is

(B) As in part (A), the probability that y=0 is (C) Let ω0 (ω1) be the state where the X (Y) process generates

a data point. We want Pr(ω0 |Z=0). Using Bayes’ rule and working with the probability densities to get the total probability:

Pr(0 0) ( ) 0. x p x dx

Example – 3 solutions

< ≤ = =

Pr(0 0) ( ) 0. y p y dy < ≤ = =

slide-15
SLIDE 15

236607 Visual Recognition Tutorial 15

where

Example - 3

1 1

( 0 | )Pr( ) ( 0 | )Pr( ) Pr( | 0) ( 0) ( 0 | )Pr( ) ( 0 | )Pr( ) 0.5 ( 0) ( 0) 0.5 ( 0) 0.5 ( 0) ( 0) ( 0) 0.3989 0.6224 0.3989 0.2420

X X X Y X Y

p Z p Z Z p Z p Z p Z p X p X p X p Y p X p Y ω ω ω ω ω ω ω ω ω = = = = = = = + = = = = = = + = = + = = = +

2 2 ( 1) 2 2

1 1 ( ) ( ) 2 2

y x

X Y

p x e p y e π π

− −

= , =

slide-16
SLIDE 16

236607 Visual Recognition Tutorial 16

A game: 3 doors, there is a prize behind one of them. You have to select one door. Then one of the other two doors is opened (not revealing the prize). At this point you may either stick with your door, or switch to the other (still closed) door. Should one stick with his initial choice, or switch, and does your choice make any difference at all?

Example 4 The game of three doors

slide-17
SLIDE 17

236607 Visual Recognition Tutorial 17

Let Hi denote the hypothesis “the prize is behind the door i ”. Assumption: Suppose w.l.o.g.: initial choice of door 1,then door 3 is

  • pened. We can stick with 1 or switch to 2.

Let D denote the door which is opened by the host. We assume: By Bayes’ formula:

The game of three doors

1 2 3

1 Pr( ) Pr( ) Pr( ) 3 H H H = = =

1 2 3 1 2 3

1 Pr( 2 | ) ,Pr( 2 | ) 0,Pr( 2 | ) 1, 2 1 Pr( 3| ) ,Pr( 3| ) 1,Pr( 3| ) 2 D H D H D H D H D H D H = = = = = = = = = = = =

1 2 3

Pr( 3| )Pr( ) Pr( | 3) , Pr( 3) 1 1 1 1 2 3 3 Pr( | 3) ,Pr( | 3) ,Pr( | 3)

i i i

D H H H D D H D H D H D Pr( 3) Pr( 3) D D = = = = = = = = = = ฀ = =

slide-18
SLIDE 18

236607 Visual Recognition Tutorial 18

The denominator is a normalizing factor. So we get which means that we are more likely to win the prize if we switch to the door 2.

The game of three doors-the solutiion

1 Pr( 3) 2 D = =

1 2 3

1 Pr( | 3) , 2 2 Pr( | 3) , 3 Pr( | 3) 0, H D H D H D = = = = = =

slide-19
SLIDE 19

236607 Visual Recognition Tutorial 19

A violent earthquake occurs just before the host has opened

  • ne of the doors; door 3 is opened accidentally, and there is

no prize behind it. The host says “it is valid door, let’s let it stay open and go on with the game”. What should we do now? First, any number of doors might have been opened by the

  • earthquake. There are 8 possible outcomes, which we assume

to be equiprobable: d=(0,0,0),…,d=(1,1,1). A value of D now consists of the outcome of the quake, and the visibility of the prize; e.g., <(0,0,1),NO> We have to compare Pr(H1|D) vs. Pr(H2|D) .

Further complication

slide-20
SLIDE 20

236607 Visual Recognition Tutorial 20

Pr(D|Hi) hard to estimate, but we know that Pr(D|H3)=0 . Also from Pr(H3 , D)= Pr(H3 | D)Pr(D)= Pr(D|H3) Pr(H3) and from we have Pr(H3 | D)=0. Further, we have to assume that Pr(D|H1)= Pr(D|H2) (we don’t know the values, but we assume they are equal). Now we have

Pr( ) D

The earthquake-continued

slide-21
SLIDE 21

236607 Visual Recognition Tutorial 21

(why they are ½?) (Because and we get Also ) So, we might just as well stick with our choice. We have different outcome because the data here is of different nature (although looks the same).

The earthquake-continued

1 1 1 2 2 2

Pr( | )Pr( ) 1 Pr( | ) , Pr( ) 2 Pr( | )Pr( ) 1 Pr( | ) Pr( ) 2 D H H H D D D H H H D D = = = =

1 2

Pr( ) Pr( ) H H =

1 2

Pr( | ) Pr( | ) D H D H =

1 2

Pr( | ) Pr( | ) H D H D =

1 2 3

Pr( | ) Pr( | ) Pr( | ) 1 H D H D H D + + =