SlideShare a Scribd company logo
1 of 67
Download to read offline
Bayesian Networks
                  Unit 1
             Probability Review
              Wang, Yuan-Kai, 王元凱
                    ykwang@mails.fju.edu.tw
                     http://www.ykwang.tw

    Department of Electrical Engineering, Fu Jen Univ.
                  輔仁大學電機工程系

                               2006~2011

                       Reference this document as:
   Wang, Yuan-Kai, “Probability Review," Lecture Notes of Wang, Yuan-Kai,
                     Fu Jen University, Taiwan, 2008.
Fu Jen University   Department of Electronic Engineering   Yuan-Kai Wang Copyright
王元凱                              Unit - Probability Review                      p. 2



                    Goal of this Unit
         Review basic concepts of
          probability in terms of
           Image processing terminologies




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 3



                     Related Units
         Next units
           Statistics Review
           Uncertainty Inference (Discrete)
           Uncertainty Inference (Continuous)




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 4



                          Self-Study
         Probability Theory textbook
         Artificial Intelligence: a modern
          approach
           Russell & Norvig, 2nd, Prentice Hall,
            2003. pp.462~474,
           Chapter 13, Sec. 13.1~13.3




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                 Unit - Probability Review                      p. 5




                              Contents
      1.   Probability .........................................           6
      2.   Random Variable ..............................                  9
      3.   Probability Distribution ....................                  19
      4.   Joint Distribution ..............................              26
      5.   Conditional Probability ....................                   46
      6.   Bayes Theorem .................................                59
      7.   Summary ……………………………..                                          64
      8.   References …………………………..                                        67



Fu Jen University      Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 6



                       1. Probability
     We   write P(A) as “the fraction of
        possible worlds in which A is true”
    Event space
    of all possible
    worlds                                    Worlds in           P(A) = Area of
                                              which A is
                                              true                reddish oval

    Its area is 1
                          Worlds in which A is False




Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 7



          The Axioms of Probability
    0   P(A)  1
     P(True) = 1
     P(False) = 0
     P(A  B) = P(A) + P(B) - P(A  B)
         Where do these axioms come
          from?
         Were they “discovered”?
         Answers coming up later.
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 8



        Theorems from the Axioms
    0       P(A)  1,
     P(True) = 1,
     P(False) = 0
    P(A  B) = P(A) + P(B) - P(A  B)
       From these we can prove:
       P(not A) = P(~A) = 1-P(A)
       P(A) = P(A  B) + P(A  ~B)
    How?
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 9



                    2. Random Variable
    A        variable with randomness
         probability, degree of belief
    An             example
         Rain : a random variable
         Its possible values: true, false
         Its randomness
          P(Rain=true)=0.8,
          P(Rain=false)=0.2
Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 10



         Types of Random Variable
      Boolean            random variable
           Rain : true, false
      Discrete    random variable
          (Multivalued R.V.)
           Rain: cloudy, sunny, drizzle,
            drench
      Continuous                  random variable
           Rain: rainfall in millimeter

Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                 Unit - Probability Review                      p. 11



                     Discrete R.V. (1/4)
    Let            A=Rain
         A can take on more than 2 values
         A is a random variable with arity k
          if it can take on exactly one value
          out of {v1,v2, .. vk}
         Thus
             P ( A  vi  A  v j )  0 if i  j
             P ( A  v1  A  v2    A  vk )  1

Fu Jen University      Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                      p. 12



                    Discrete R.V. (2/4)
                                                                i
    P( A  v1  A  v2    A  vi )   P( A  v j )
                                                               j 1
      Prove it?
    Using the axioms of probability…
        0  P(A)  1, P(True) = 1, P(False) = 0
        P(A  B) = P(A) + P(B) - P(A  B)
     And assume that A obeys

              P ( A  vi  A  v j )  0 if i  j
              P( A  v1  A  v2    A  vk )  1
Fu Jen University    Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                           p. 13



                    Discrete R.V. (3/4)
                                                               i
      P( A  v1  A  v2    A  vi )   P( A  v j )
                     k                                        j 1

                      P( A  v )  1
                     j 1
                                           j

    Using the axioms of probability…
        0  P(A)  1, P(True) = 1, P(False) = 0
        P(A or B) = P(A) + P(B) - P(A and B)
     And assuming that A obeys…
        P( A  vi  A  v j )  0 if i  j
        P( A  v1  A  v2    A  vk )  1
Fu Jen University    Department of Electrical Engineering          Wang, Yuan-Kai Copyright
王元凱                                  Unit - Probability Review                           p. 14



                    Discrete R.V. (4/4)
                                                                  i
   P( B  [ A  v1  A  v2    A  vi ])   P( B  A  v j )
                                                                 j 1
                                 k
                    P( B)   P( B  A  v j )
                                j 1
    Using the axioms of probability…
        0  P(A)  1, P(True) = 1, P(False) = 0
        P(A or B) = P(A) + P(B) - P(A and B)
     And assuming that A obeys…
        P( A  vi  A  v j )  0 if i  j
        P( A  v1  A  v2    A  vk )  1
Fu Jen University     Department of Electrical Engineering            Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 15



                    Random Vector
         A random vector is a vector of
          random variables
           X = (X1, X2, ..., XN)
           X1 ... XN are random variables




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                      p. 16



      Example in Image Processing
         For a gray-level image,
          random variable is “gray level”
    • Random variable X
      (Gray level) has n
      possible values
      {x1, x2, ..., xn}, n=256
    • N random data
      x1, x2, .., xN of X,
      N=Width*Height
         Discrete v.s. continuous ?
Fu Jen University    Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 17



      Example in Image Processing
         For a color image,
          random vector is (r,g,b)




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 18



      Example in Computer Vision
         Random vector is a vector of
          “features”
           Face recognition




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 19



          3. Probability Distribution
        Probability distribution is a set of
         probabilities
          Boolean R.V.
            P(A): P(A=true)=0.2, P(A=false)=0.8
          Discrete R.V.
            P(A): P(A=v1)=0.2, P(A=v2)=0.4,
                   P(A=v3)=0.4, P(A=v4)=0.1,
          Continuous R.V.
        Usually we plot the probability
         distribution as a function
         (Probability Distribution Function,
         pdf)
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                      Unit - Probability Review                      p. 20



       Probability Distribution (1/3)
      Continuous                       R.V.
                    0.8
                    0.6
                    0.4
                    0.2
                      0                                              Rain (mm)
                          0 100 200 300 400 500 600

                •         P(Rain) is a probability
                          density function (pdf)
                •         P(Rain=200) is a probability
Fu Jen University           Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 21



        Probability Distribution(2/3)
    Boolean           R.V.
         P(Rain) is a probability distribution
         P(Rain=false) is a probability
                    P(Rain)
                     0.8

                     0.2
                                                           Rain
                            false         true

Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                 Unit - Probability Review                        p. 22



        Probability Distribution(3/3)
      Discrete         R.V.
          P(Rain) is a probability distribution
          P(Rain=drizzle) is a probability
                    P(Rain)
                     0.8

                     0.2
                                                                Rain
                                                      drench
                           cloudy


                                            drizzle
                                    sunny




Fu Jen University    Department of Electrical Engineering         Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 23



                    Common Probability
                       Distributions
      Normal  distribution (Gaussian)
        Parameters: , 
        Discussed in Section 3
      Uniform distribution
      Exponential distribution
      Poisson distribution
      ...

Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                  Unit - Probability Review                          p. 24



            The Uniform Distribution
                                                                     1                 w
                                                                      w if      | x |
                                        P(x)                 p( x)                    2
                                                                                        w
                                                                      0 if      | x |
                                                                                       2


      1/w


                                                                                X
                     -w/2                  0                     w/2
                                                                 2
                                                   w
                    E[ X ]  0          Var[ X ] 
                                                   12
Fu Jen University       Department of Electrical Engineering         Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 25



      Example in Image Processing




   • Random variable X (Gray level) has n possible
     values {x1, x2, ..., xn}, n=256
   • Distribution P(xi) of the image
       •Is not a usual p.d.f.
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 26



                    4. Joint Distribution
         When there are more than one
          random variables: X, Y
           We want to know "the probabilities
            of both random variables"
           Joint probability distribution
             P(X  Y)
             P(X  Y  ...)

Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 27



                       An Example
      A    set of random variables for the
          typhoon world
            Rain, Wind, Speed, ...
            Every random variable
              Describes one facet of typhoon
              Has a probability distribution
            A typhoon is a situation of joint
             probability
              P(Rain=200mm  Wind=South 
                 Speed=100km/hr) = 0.4

Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                   Unit - Probability Review                            p. 28



        P(X,Y) with X Y are Discrete
         P(X,Y) : (M x N) entries
                    y1 P(X=x1,Y=y1) P(X=x2,Y=y1) P(X=x3,Y=y1)
          Y
                    y2 P(X=x1,Y=y2) P(X=x2,Y=y2) P(X=x3,Y=y2)
                            x1           x2           x3
                                         X

                         y1     0.2            0.1                0.1
                    Y
                         y2     0.1            0.2                0.3
                                 x1             x2                x3
                                                X
Fu Jen University        Department of Electrical Engineering           Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 29



                       Atomic Event
      Atomic          event is a
          Combination of values of all random
           variables
          Situation (state) of typhoon
           (statistical world)
      For          the typhoon example
          (Rain=200mm  Wind=South 
           Speed=100km/hr) is an atomic event
          (Rain=200mm  Wind=South) is not
Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 30



      Joint Probability Distribution
     P(Rain=200mm      Wind=South 
      Speed=100km/hr) is a joint probability
     P(Rain  Wind  Speed) is a probability
      of all joint probabilities
          Joint probability function
    A   set of random variables can have
        mixed types
          Ex: Rain: Boolean, Wind: Discrete,
           Speed: Continuous
          We will consider all-discrete case
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 31



      Prior and Joint Probability
                  (Math)
    Let {X1,...,Xn} be a set of
     random variables
         P(Xi) is a probability function
         P(Xi=xi) is a prior probability
         P(X1  X2    Xn) is a joint
          probability function
         P(X1=x1  X2=x2    Xn=xn) is
          a joint probability
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                 Unit - Probability Review                      p. 32



       For Boolean & Discrete R.V.
      Let          X be a single R.V.
          P(X) is a vector
      Boolean            R.V.
          Rain: true, false
          P(Rain) = <0.72, 0.28>
      Discrete           R.V.
          Rain: cloudy, sunny, drizzle, drench
          P(Rain) = <0.72, 0.1, 0.08, 0.1>
          Normalized, i.e. sums to 1
Fu Jen University      Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 33



         Full Joint Distribution (1/3)
   For   a set of random variables
    { X1 , X2 ,  , Xn }
   X1  X2    Xn are atomic events
   P(X1  X2    Xn) is
        A full joint probability distribution
         (FJD)
        A table of all joint prob. of all atomic
         events, if {X1,  , Xn} are discrete
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                 Unit - Probability Review                      p. 34



         Full Joint Distribution (2/3)
      Ex:          X1: Rain, X2: Wind
          X1: drizzle, drench, cloudy,
          X2: strong, weak
          X1  X2 are atomic events
          P(X1  X2) is a 3x2 matrix of values
                     Rain Drizzle                   Drench         Cloudy
        Wind
        Strong                 0.15                 0.12           0.06
        Weak                   0.55                 0.08           0.04
             P(X1=drizzle  X2=strong) = 0.15, ...
Fu Jen University      Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 35



         Full Joint Distribution (3/3)
      All    questions about probability
          of joint events can be answered
          by the table
           P(Wind=Strong),
            P(Rain=Drizzle  Wind=Strong),
            ...


Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                          p. 36



       An Example with 3 Boolean
              R.V. (1/2)
                                       Boolean variables A, B, C
  1. Make a truth table
     listing all                                    A        B       C
     combinations of                                0        0       0
     values of your                                 0        0       1
     variables                                      0        1       0
     • if there are M                               0        1       1
        Boolean variables                           1        0       0
        then the table will                         1        0       1
                                                    1        1       0
        have 2M rows
                                                    1        1       1
Fu Jen University   Department of Electrical Engineering         Wang, Yuan-Kai Copyright
王元凱                                           Unit - Probability Review                          p. 37



      An Example with 3 Boolean
             R.V. (2/2)
      2. For each                                         A         B     C Prob
         combination of                                   0       0       0      0.30
         values, say how                                  0       0       1      0.05
         probable it is                                   0       1       0      0.10
                                                          0       1       1      0.05
      A    0.05      0.10          0.05                   1       0       0      0.05
                     0.10                                 1       0       1      0.10
              0.25
                            0.05          C               1       1       0      0.25
                     0.10                                 1       1       1      0.10
    0.30      B
                                                                Sum              1.0
Fu Jen University           Department of Electrical Engineering              Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                                p. 38



                    Using the FJD
    • Once you have the FJD
    • You can ask for the probability of
      any logical expression: Inference


                                                             P( E )          P(row )
                                                                        rows matching E




Fu Jen University   Department of Electrical Engineering        Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 39



        Examples of Inference (1/3)
    P(Poor Male) = 0.4654                         P( E )          P(row )
                                                             rows matching E




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                        p. 40



        Examples of Inference (2/3)
      P(Poor) = 0.7604                          P( E )            P(row )
                                                             rows matching E




Fu Jen University   Department of Electrical Engineering       Wang, Yuan-Kai Copyright
王元凱                                 Unit - Probability Review                          p. 41



        Examples of Inference (3/3)




                             P ( E1  E2 )
                                                                 P(row )
             P ( E1 | E2 )                
                                                    rows matching E1 and E2

                                P ( E2 )                         P(row )
                                                      rows matching E2

                P(Male | Poor) = 0.4654 / 0.7604 = 0.612
Fu Jen University      Department of Electrical Engineering         Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 42



               Inference is a Big Deal
 I’ve got this evidence
 What’s the chance that                                     this
      conclusion is true?
      I’ve got a sore neck: how likely am
       I to have meningitis?
      I see my lights are out and it’s
       9pm. What’s the chance my
       spouse is already asleep?

Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 43



             Where do Full Joint
          Distributions Come from?
                     (1/2)
     Idea One: Expert Humans
     Idea Two: Learn them from data!




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                  Unit - Probability Review                          p. 44


        Where do FJD Come from?
                  (2/2)
   Build a JD table for your                 Then fill in each row with
   attributes in which the
   probabilities are unspecified             ˆ (row )  records matching row
                                             P
                                                        total number of records
   A        B       C     Prob
   0        0       0     ?                              A       B       C       Prob
   0        0       1     ?                              0       0       0       0.30
   0        1       0     ?                              0       0       1       0.05
   0        1       1     ?                              0       1       0       0.10
   1        0       0     ?                              0       1       1       0.05
   1        0       1     ?                              1       0       0       0.05
   1        1       0     ?                              1       0       1       0.10
   1        1       1     ?                              1       1       0       0.25
                                                         1       1       1       0.10
       Fraction of all records in which
       A and B are True but C is False
Fu Jen University       Department of Electrical Engineering         Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 45



        Example of Learning a FJD
     This   Joint was obtained by
        learning from three attributes in
        the UCI “Adult” Census Database
        [Kohavi 1995]




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                  Unit - Probability Review                      p. 46



          5. Conditional Probability
     P(A|B)     = Fraction of worlds in which B
        is true that also have A true
                                     H = “Have a headache”
                    F
                                     F = “Coming down with Flu”
                        H
                                     P(H) = 1/10
                                     P(F) = 1/40
                                     P(H|F) = 1/2
            “Headaches are rare and flu is rarer, but if
            you’re coming down with ‘flu there’s a 50-
            50 chance you’ll have a headache”
Fu Jen University       Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                   Unit - Probability Review                      p. 47



                                  Formula
                                   H = “Have a headache”
                F
                                   F = “Coming down with Flu”
                    H

                                   P(H) = 1/10
                                   P(F) = 1/40
                                   P(H|F) = 1/2
                                 P( H  F )
                    P( H | F ) 
                                   P( F )
                        P(H|F) v.s. P(HF)
Fu Jen University        Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                   Unit - Probability Review                      p. 48



             Conditional, Joint, Prior
       Relationship   among conditional,
         joint, and prior probabilities
                    P(X1  X2)P(X2)
   P(X1)                                                  P( X 1  X 2 )
                                         P( X 1 | X 2 ) 
                                                            P( X 2 )
                                         P( X1  X 2 )  P( X1 | X 2 )P( X 2 )




Fu Jen University        Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 49



                    Posterior v.s. Prior
                      Probabilities
    P(Cavity|Toothache)
         Conditional probability
         Posterior probability
          (after the fact/evidence)
    P(Cavity)
         Prior probability (the fact)

Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 50



            An Example (1/2)
      For a dental diagnosis
           Let {Cavity,Toothache} be a set
            of Boolean random variables
      Denotations                  for Boolean R.V.
           P(Cavity=true) = P(cavity)
           P(Cavity=false) = P(cavity)



Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                  Unit - Probability Review                         p. 51



                      An Example (2/2)
      The   full joint probability
        distribution P(Toothache  Cavity)
                                toothache toothache
                    cavity         0.04      0.06
                    cavity         0.01                         0.89
    P(cavity  toothache)  0.04  0.01  0.06  0.11
     P(cavity| toothache )
       P(cavity toothache )      0.04
                                          0.80
          P(toothache  )       0.04  0.01
Fu Jen University       Department of Electrical Engineering        Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 52



    Conditional Probability (Math)
   P(X1=x1i| X2 =x2j) is a conditional
    probability
   P(X1 | X2) is a conditional
    distribution function
        All P(X1=x1i| X2 =x2j) for all possible i, j
   For   Boolean & discrete R.V.s,
      conditional distribution function is a
      conditional probability table
        Conditional distribution of continuous
         R.V. will not used in our discussions
Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                      p. 53



     Conditional Probability Table
                  (CPT)
   For the dental diagnosis problem,
        Toothache & Cavity are Boolean R.V.s
        P(Toothache|Cavity) is a CPT
  Cavity P(toothache|Cavity) P(toothache|Cavity)
   T          0.90                   0.1
   F          0.05                   0.95
                    Cavity       P(toothache|Cavity)
                     T               0.90
                     F               0.05
Fu Jen University     Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                  Unit - Probability Review                         p. 54



                          CPT v.s. FJD
                               toothache toothache
                    cavity        0.04      0.06
                    cavity         0.01                         0.89
               Sum of all atomic events = 1
  Cavity P(toothache|Cavity) P(toothache|Cavity)
   T          0.90                   0.1
   F          0.05                   0.95
                             Sum of a row = 1

Fu Jen University       Department of Electrical Engineering        Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                      p. 55



               More Than 2 Random
                   Variables in
              Conditional Probability
      Joint       conditional probability
              P( X1  X 2 | X 3  X 4 )
                P( X1  X 2  X 3  X 4 )
              
                     P( X 3  X 4 )
               P( X1 | X 2  X 3  X 4 )P( X 2 | X 3  X 4 )

Fu Jen University    Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                Unit - Probability Review                         p. 56



                           Chain Rule
    • Joint probability can be calculated
      from a chain of conditional
      probability P( X | X )  P( X 1  X 2 )
                                         1         2
                                                               P( X 2 )
      P( X 1  X 2 )  P( X 1 | X 2 ) P( X 2 )
      P( X1  X 2  X 3  X 4 )
       P( X1  ( X 2  X 3  X 4 ))
       P( X1 | X 2  X 3  X 4 )P( X 2  X 3  X 4 )
       P( X1 | X 2  X 3  X 4 )P( X 2 | X 3  X 4 )P( X 3 | X 4 )P( X 4 )
                                               n
      P( X1  X 2  X n )   P( X i | X i 1  X n )
                                              i 1
Fu Jen University     Department of Electrical Engineering        Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                      p. 57



        Useful Easy-to-prove Facts

                    P( A | B)P(A | B )  1
                       nA

                       P( A  v
                       k 1
                                               k   | B)  1




Fu Jen University    Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 58



                    Where Are We?
     We  have recalled the fundamentals
      of probability
     We know what JDs are and how to
      use them
     Next two sections
          Bayes rule
          Gaussian distribution


Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                   Unit - Probability Review                      p. 59



                    6. Bayes Theorem
                               P ( A | B ) P ( A)
                                          
                               P ( B | A) P ( B )
      P( A  B)  P( A | B) P( B)
     P ( B  A)  P ( B | A) P ( A)
    P ( A | B ) P ( B )  P ( B | A) P ( A)
       Bayes, Thomas (1763) An essay
       towards solving a problem in the
       doctrine of chances. Philosophical
       Transactions of the Royal Society of
       London, 53:370-418

Fu Jen University        Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                      p. 60



       Useful Forms of Bayes Rule
                  P( B | A) P( A)   P( A  B)
      P( A | B)                  
                      P( B)          P( B)
                              P( B | A  C ) P( A  C )
              P( A |B  C ) 
                                     P( B  C )
                P( B | A, C ) P( A, C ) P( B | A, C ) P( A | C )
 P( A |B, C )                         
                       P ( B, C )              P( B | C )

Fu Jen University    Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                                 Unit - Probability Review                         p. 61


                    More General Forms
                      of Bayes Rule
    If A is a Boolean R.V.
                P( A  B)           P( A  B)
     P( A |B)            
                 P( B)      P ( A  B )  P ( A  B )
    If A is a discrete R.V.
                       P( A  vi  B)                   P(B | A  vi )P( A  vi )
   P( A  vi |B)     nA
                                                    nA

                     P(A  v  B) P(B | A  v )P(A  v )
                     k 1
                                    k
                                                    k 1
                                                                     k            k



Fu Jen University      Department of Electrical Engineering      Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                      p. 62



                  Example –
            Bayesian Detection (1/2)
         2-class recognition
           Ex.: Skin color detection
         Let
           A be skin color pixel
           A be non-skin color pixel
           c be the color (R,G,B) of a pixel
         We can get : P(c|A), P(c|A)
         For a pixel in a new image, is it a skin
          color pixel?
                  P(c | A) P( A)                         P(c | A) P(A)
      P( A | c)                        > P ( A | c ) 
                      P (c )                                   P (c )
Fu Jen University    Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                      p. 63



                  Example –
            Bayesian Detection (2/2)
         2-class recognition
           Ex.: Background detection
         Let
           A be background pixel
           A be non-background pixel
           c be the color (R,G,B) of a pixel
         We can get : P(c|A), P(c|A)
         For a pixel in a new image, is it a
          background pixel?
                  P(c | A) P( A)                         P(c | A) P(A)
      P( A | c)                        > P ( A | c ) 
                      P (c )                                   P (c )
Fu Jen University    Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                               Unit - Probability Review                             p. 64



                        7. Summary
                    Continuous variable                         Discrete variable
                                                              (X has M values, Y has N values)
    P(X)            Function of one variable                     M vector
    P(X=x)          Scalar*                                      Scalar
    P(X,Y)          Function of two variables MxN matrix
    P(X|Y)          Function of two variables MxN matrix
    P(X|Y=y)        Function of one variable                     M vector
    P(X=x|Y)        Function of one variable                     N vector
    P(X=x|Y=y) Scalar*                                           Scalar
Fu Jen University    Department of Electrical Engineering            Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 65



                              Ex (1/2)




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 66



                              Ex (2/2)




Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright
王元凱                              Unit - Probability Review                      p. 67



                       8. Reference
         Artificial Intelligence: a modern
          approach
           Russell & Norvig, 2nd, Prentice Hall, 2003.
           Sections 13.1~13.3, pp.462~474.
         統計學的世界
           墨爾著,鄭惟厚譯
           天下文化,2002
         深入淺出統計學
           D. Grifiths, 楊仁和譯,2009
           O’ Reilly

Fu Jen University   Department of Electrical Engineering     Wang, Yuan-Kai Copyright

More Related Content

More from IEEE International Conference on Intelligent Information Hiding and Multimedia Signal Processing

More from IEEE International Conference on Intelligent Information Hiding and Multimedia Signal Processing (11)

Computer Vision in the Age of IoT
Computer Vision in the Age of IoTComputer Vision in the Age of IoT
Computer Vision in the Age of IoT
 
2014/07/17 Parallelize computer vision by GPGPU computing
2014/07/17 Parallelize computer vision by GPGPU computing2014/07/17 Parallelize computer vision by GPGPU computing
2014/07/17 Parallelize computer vision by GPGPU computing
 
Towards Embedded Computer Vision - New @ 2013
Towards Embedded Computer Vision - New @ 2013Towards Embedded Computer Vision - New @ 2013
Towards Embedded Computer Vision - New @ 2013
 
Parallel Vision by GPGPU/CUDA
Parallel Vision by GPGPU/CUDAParallel Vision by GPGPU/CUDA
Parallel Vision by GPGPU/CUDA
 
07 approximate inference in bn
07 approximate inference in bn07 approximate inference in bn
07 approximate inference in bn
 
06 exact inference in bn
06 exact inference in bn06 exact inference in bn
06 exact inference in bn
 
08 probabilistic inference over time
08 probabilistic inference over time08 probabilistic inference over time
08 probabilistic inference over time
 
Monocular Human Pose Estimation with Bayesian Networks
Monocular Human Pose Estimation with Bayesian NetworksMonocular Human Pose Estimation with Bayesian Networks
Monocular Human Pose Estimation with Bayesian Networks
 
Towards Embedded Computer Vision邁向嵌入式電腦視覺
Towards Embedded Computer Vision邁向嵌入式電腦視覺Towards Embedded Computer Vision邁向嵌入式電腦視覺
Towards Embedded Computer Vision邁向嵌入式電腦視覺
 
Intelligent Video Surveillance with Cloud Computing
Intelligent Video Surveillance with Cloud ComputingIntelligent Video Surveillance with Cloud Computing
Intelligent Video Surveillance with Cloud Computing
 
Intelligent Video Surveillance and Sousveillance
Intelligent Video Surveillance and SousveillanceIntelligent Video Surveillance and Sousveillance
Intelligent Video Surveillance and Sousveillance
 

Recently uploaded

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 

Recently uploaded (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 

Fu Jen University Probability Review Document

  • 1. Bayesian Networks Unit 1 Probability Review Wang, Yuan-Kai, 王元凱 ykwang@mails.fju.edu.tw http://www.ykwang.tw Department of Electrical Engineering, Fu Jen Univ. 輔仁大學電機工程系 2006~2011 Reference this document as: Wang, Yuan-Kai, “Probability Review," Lecture Notes of Wang, Yuan-Kai, Fu Jen University, Taiwan, 2008. Fu Jen University Department of Electronic Engineering Yuan-Kai Wang Copyright
  • 2. 王元凱 Unit - Probability Review p. 2 Goal of this Unit  Review basic concepts of probability in terms of  Image processing terminologies Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 3. 王元凱 Unit - Probability Review p. 3 Related Units  Next units  Statistics Review  Uncertainty Inference (Discrete)  Uncertainty Inference (Continuous) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 4. 王元凱 Unit - Probability Review p. 4 Self-Study  Probability Theory textbook  Artificial Intelligence: a modern approach  Russell & Norvig, 2nd, Prentice Hall, 2003. pp.462~474,  Chapter 13, Sec. 13.1~13.3 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 5. 王元凱 Unit - Probability Review p. 5 Contents 1. Probability ......................................... 6 2. Random Variable .............................. 9 3. Probability Distribution .................... 19 4. Joint Distribution .............................. 26 5. Conditional Probability .................... 46 6. Bayes Theorem ................................. 59 7. Summary …………………………….. 64 8. References ………………………….. 67 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 6. 王元凱 Unit - Probability Review p. 6 1. Probability  We write P(A) as “the fraction of possible worlds in which A is true” Event space of all possible worlds Worlds in P(A) = Area of which A is true reddish oval Its area is 1 Worlds in which A is False Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 7. 王元凱 Unit - Probability Review p. 7 The Axioms of Probability 0  P(A)  1  P(True) = 1  P(False) = 0  P(A  B) = P(A) + P(B) - P(A  B) Where do these axioms come from? Were they “discovered”? Answers coming up later. Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 8. 王元凱 Unit - Probability Review p. 8 Theorems from the Axioms 0  P(A)  1, P(True) = 1, P(False) = 0 P(A  B) = P(A) + P(B) - P(A  B) From these we can prove: P(not A) = P(~A) = 1-P(A) P(A) = P(A  B) + P(A  ~B) How? Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 9. 王元凱 Unit - Probability Review p. 9 2. Random Variable A variable with randomness probability, degree of belief An example Rain : a random variable Its possible values: true, false Its randomness P(Rain=true)=0.8, P(Rain=false)=0.2 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 10. 王元凱 Unit - Probability Review p. 10 Types of Random Variable Boolean random variable Rain : true, false Discrete random variable (Multivalued R.V.) Rain: cloudy, sunny, drizzle, drench Continuous random variable Rain: rainfall in millimeter Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 11. 王元凱 Unit - Probability Review p. 11 Discrete R.V. (1/4) Let A=Rain A can take on more than 2 values A is a random variable with arity k if it can take on exactly one value out of {v1,v2, .. vk} Thus P ( A  vi  A  v j )  0 if i  j P ( A  v1  A  v2    A  vk )  1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 12. 王元凱 Unit - Probability Review p. 12 Discrete R.V. (2/4) i P( A  v1  A  v2    A  vi )   P( A  v j ) j 1 Prove it? Using the axioms of probability… 0  P(A)  1, P(True) = 1, P(False) = 0 P(A  B) = P(A) + P(B) - P(A  B)  And assume that A obeys P ( A  vi  A  v j )  0 if i  j P( A  v1  A  v2    A  vk )  1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 13. 王元凱 Unit - Probability Review p. 13 Discrete R.V. (3/4) i P( A  v1  A  v2    A  vi )   P( A  v j ) k j 1  P( A  v )  1 j 1 j Using the axioms of probability… 0  P(A)  1, P(True) = 1, P(False) = 0 P(A or B) = P(A) + P(B) - P(A and B)  And assuming that A obeys… P( A  vi  A  v j )  0 if i  j P( A  v1  A  v2    A  vk )  1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 14. 王元凱 Unit - Probability Review p. 14 Discrete R.V. (4/4) i P( B  [ A  v1  A  v2    A  vi ])   P( B  A  v j ) j 1 k P( B)   P( B  A  v j ) j 1 Using the axioms of probability… 0  P(A)  1, P(True) = 1, P(False) = 0 P(A or B) = P(A) + P(B) - P(A and B)  And assuming that A obeys… P( A  vi  A  v j )  0 if i  j P( A  v1  A  v2    A  vk )  1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 15. 王元凱 Unit - Probability Review p. 15 Random Vector  A random vector is a vector of random variables  X = (X1, X2, ..., XN)  X1 ... XN are random variables Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 16. 王元凱 Unit - Probability Review p. 16 Example in Image Processing  For a gray-level image, random variable is “gray level” • Random variable X (Gray level) has n possible values {x1, x2, ..., xn}, n=256 • N random data x1, x2, .., xN of X, N=Width*Height Discrete v.s. continuous ? Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 17. 王元凱 Unit - Probability Review p. 17 Example in Image Processing  For a color image, random vector is (r,g,b) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 18. 王元凱 Unit - Probability Review p. 18 Example in Computer Vision  Random vector is a vector of “features”  Face recognition Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 19. 王元凱 Unit - Probability Review p. 19 3. Probability Distribution  Probability distribution is a set of probabilities  Boolean R.V.  P(A): P(A=true)=0.2, P(A=false)=0.8  Discrete R.V.  P(A): P(A=v1)=0.2, P(A=v2)=0.4, P(A=v3)=0.4, P(A=v4)=0.1,  Continuous R.V.  Usually we plot the probability distribution as a function (Probability Distribution Function, pdf) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 20. 王元凱 Unit - Probability Review p. 20 Probability Distribution (1/3) Continuous R.V. 0.8 0.6 0.4 0.2 0 Rain (mm) 0 100 200 300 400 500 600 • P(Rain) is a probability density function (pdf) • P(Rain=200) is a probability Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 21. 王元凱 Unit - Probability Review p. 21 Probability Distribution(2/3) Boolean R.V. P(Rain) is a probability distribution P(Rain=false) is a probability P(Rain) 0.8 0.2 Rain false true Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 22. 王元凱 Unit - Probability Review p. 22 Probability Distribution(3/3) Discrete R.V. P(Rain) is a probability distribution P(Rain=drizzle) is a probability P(Rain) 0.8 0.2 Rain drench cloudy drizzle sunny Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 23. 王元凱 Unit - Probability Review p. 23 Common Probability Distributions Normal distribution (Gaussian) Parameters: ,  Discussed in Section 3 Uniform distribution Exponential distribution Poisson distribution ... Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 24. 王元凱 Unit - Probability Review p. 24 The Uniform Distribution 1 w  w if | x | P(x) p( x)   2 w  0 if | x |  2 1/w X -w/2 0 w/2 2 w E[ X ]  0 Var[ X ]  12 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 25. 王元凱 Unit - Probability Review p. 25 Example in Image Processing • Random variable X (Gray level) has n possible values {x1, x2, ..., xn}, n=256 • Distribution P(xi) of the image •Is not a usual p.d.f. Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 26. 王元凱 Unit - Probability Review p. 26 4. Joint Distribution  When there are more than one random variables: X, Y  We want to know "the probabilities of both random variables"  Joint probability distribution  P(X  Y)  P(X  Y  ...) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 27. 王元凱 Unit - Probability Review p. 27 An Example A set of random variables for the typhoon world  Rain, Wind, Speed, ...  Every random variable Describes one facet of typhoon Has a probability distribution  A typhoon is a situation of joint probability P(Rain=200mm  Wind=South  Speed=100km/hr) = 0.4 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 28. 王元凱 Unit - Probability Review p. 28 P(X,Y) with X Y are Discrete  P(X,Y) : (M x N) entries y1 P(X=x1,Y=y1) P(X=x2,Y=y1) P(X=x3,Y=y1) Y y2 P(X=x1,Y=y2) P(X=x2,Y=y2) P(X=x3,Y=y2) x1 x2 x3 X y1 0.2 0.1 0.1 Y y2 0.1 0.2 0.3 x1 x2 x3 X Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 29. 王元凱 Unit - Probability Review p. 29 Atomic Event Atomic event is a Combination of values of all random variables Situation (state) of typhoon (statistical world) For the typhoon example (Rain=200mm  Wind=South  Speed=100km/hr) is an atomic event (Rain=200mm  Wind=South) is not Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 30. 王元凱 Unit - Probability Review p. 30 Joint Probability Distribution  P(Rain=200mm  Wind=South  Speed=100km/hr) is a joint probability  P(Rain  Wind  Speed) is a probability of all joint probabilities  Joint probability function A set of random variables can have mixed types  Ex: Rain: Boolean, Wind: Discrete, Speed: Continuous  We will consider all-discrete case Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 31. 王元凱 Unit - Probability Review p. 31 Prior and Joint Probability (Math) Let {X1,...,Xn} be a set of random variables P(Xi) is a probability function P(Xi=xi) is a prior probability P(X1  X2    Xn) is a joint probability function P(X1=x1  X2=x2    Xn=xn) is a joint probability Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 32. 王元凱 Unit - Probability Review p. 32 For Boolean & Discrete R.V. Let X be a single R.V. P(X) is a vector Boolean R.V. Rain: true, false P(Rain) = <0.72, 0.28> Discrete R.V. Rain: cloudy, sunny, drizzle, drench P(Rain) = <0.72, 0.1, 0.08, 0.1> Normalized, i.e. sums to 1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 33. 王元凱 Unit - Probability Review p. 33 Full Joint Distribution (1/3) For a set of random variables { X1 , X2 ,  , Xn } X1  X2    Xn are atomic events P(X1  X2    Xn) is A full joint probability distribution (FJD) A table of all joint prob. of all atomic events, if {X1,  , Xn} are discrete Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 34. 王元凱 Unit - Probability Review p. 34 Full Joint Distribution (2/3) Ex: X1: Rain, X2: Wind X1: drizzle, drench, cloudy, X2: strong, weak X1  X2 are atomic events P(X1  X2) is a 3x2 matrix of values Rain Drizzle Drench Cloudy Wind Strong 0.15 0.12 0.06 Weak 0.55 0.08 0.04 P(X1=drizzle  X2=strong) = 0.15, ... Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 35. 王元凱 Unit - Probability Review p. 35 Full Joint Distribution (3/3) All questions about probability of joint events can be answered by the table P(Wind=Strong), P(Rain=Drizzle  Wind=Strong), ... Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 36. 王元凱 Unit - Probability Review p. 36 An Example with 3 Boolean R.V. (1/2) Boolean variables A, B, C 1. Make a truth table listing all A B C combinations of 0 0 0 values of your 0 0 1 variables 0 1 0 • if there are M 0 1 1 Boolean variables 1 0 0 then the table will 1 0 1 1 1 0 have 2M rows 1 1 1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 37. 王元凱 Unit - Probability Review p. 37 An Example with 3 Boolean R.V. (2/2) 2. For each A B C Prob combination of 0 0 0 0.30 values, say how 0 0 1 0.05 probable it is 0 1 0 0.10 0 1 1 0.05 A 0.05 0.10 0.05 1 0 0 0.05 0.10 1 0 1 0.10 0.25 0.05 C 1 1 0 0.25 0.10 1 1 1 0.10 0.30 B Sum 1.0 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 38. 王元凱 Unit - Probability Review p. 38 Using the FJD • Once you have the FJD • You can ask for the probability of any logical expression: Inference P( E )   P(row ) rows matching E Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 39. 王元凱 Unit - Probability Review p. 39 Examples of Inference (1/3) P(Poor Male) = 0.4654 P( E )   P(row ) rows matching E Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 40. 王元凱 Unit - Probability Review p. 40 Examples of Inference (2/3) P(Poor) = 0.7604 P( E )   P(row ) rows matching E Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 41. 王元凱 Unit - Probability Review p. 41 Examples of Inference (3/3) P ( E1  E2 )  P(row ) P ( E1 | E2 )   rows matching E1 and E2 P ( E2 )  P(row ) rows matching E2 P(Male | Poor) = 0.4654 / 0.7604 = 0.612 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 42. 王元凱 Unit - Probability Review p. 42 Inference is a Big Deal I’ve got this evidence What’s the chance that this conclusion is true? I’ve got a sore neck: how likely am I to have meningitis? I see my lights are out and it’s 9pm. What’s the chance my spouse is already asleep? Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 43. 王元凱 Unit - Probability Review p. 43 Where do Full Joint Distributions Come from? (1/2)  Idea One: Expert Humans  Idea Two: Learn them from data! Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 44. 王元凱 Unit - Probability Review p. 44 Where do FJD Come from? (2/2) Build a JD table for your Then fill in each row with attributes in which the probabilities are unspecified ˆ (row )  records matching row P total number of records A B C Prob 0 0 0 ? A B C Prob 0 0 1 ? 0 0 0 0.30 0 1 0 ? 0 0 1 0.05 0 1 1 ? 0 1 0 0.10 1 0 0 ? 0 1 1 0.05 1 0 1 ? 1 0 0 0.05 1 1 0 ? 1 0 1 0.10 1 1 1 ? 1 1 0 0.25 1 1 1 0.10 Fraction of all records in which A and B are True but C is False Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 45. 王元凱 Unit - Probability Review p. 45 Example of Learning a FJD  This Joint was obtained by learning from three attributes in the UCI “Adult” Census Database [Kohavi 1995] Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 46. 王元凱 Unit - Probability Review p. 46 5. Conditional Probability  P(A|B) = Fraction of worlds in which B is true that also have A true H = “Have a headache” F F = “Coming down with Flu” H P(H) = 1/10 P(F) = 1/40 P(H|F) = 1/2 “Headaches are rare and flu is rarer, but if you’re coming down with ‘flu there’s a 50- 50 chance you’ll have a headache” Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 47. 王元凱 Unit - Probability Review p. 47 Formula H = “Have a headache” F F = “Coming down with Flu” H P(H) = 1/10 P(F) = 1/40 P(H|F) = 1/2 P( H  F ) P( H | F )  P( F ) P(H|F) v.s. P(HF) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 48. 王元凱 Unit - Probability Review p. 48 Conditional, Joint, Prior  Relationship among conditional, joint, and prior probabilities P(X1  X2)P(X2) P(X1) P( X 1  X 2 ) P( X 1 | X 2 )  P( X 2 ) P( X1  X 2 )  P( X1 | X 2 )P( X 2 ) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 49. 王元凱 Unit - Probability Review p. 49 Posterior v.s. Prior Probabilities P(Cavity|Toothache) Conditional probability Posterior probability (after the fact/evidence) P(Cavity) Prior probability (the fact) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 50. 王元凱 Unit - Probability Review p. 50 An Example (1/2) For a dental diagnosis Let {Cavity,Toothache} be a set of Boolean random variables Denotations for Boolean R.V. P(Cavity=true) = P(cavity) P(Cavity=false) = P(cavity) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 51. 王元凱 Unit - Probability Review p. 51 An Example (2/2) The full joint probability distribution P(Toothache  Cavity) toothache toothache cavity 0.04 0.06 cavity 0.01 0.89 P(cavity  toothache)  0.04  0.01  0.06  0.11 P(cavity| toothache ) P(cavity toothache ) 0.04    0.80 P(toothache ) 0.04  0.01 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 52. 王元凱 Unit - Probability Review p. 52 Conditional Probability (Math) P(X1=x1i| X2 =x2j) is a conditional probability P(X1 | X2) is a conditional distribution function All P(X1=x1i| X2 =x2j) for all possible i, j For Boolean & discrete R.V.s, conditional distribution function is a conditional probability table Conditional distribution of continuous R.V. will not used in our discussions Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 53. 王元凱 Unit - Probability Review p. 53 Conditional Probability Table (CPT) For the dental diagnosis problem, Toothache & Cavity are Boolean R.V.s P(Toothache|Cavity) is a CPT Cavity P(toothache|Cavity) P(toothache|Cavity) T 0.90 0.1 F 0.05 0.95 Cavity P(toothache|Cavity) T 0.90 F 0.05 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 54. 王元凱 Unit - Probability Review p. 54 CPT v.s. FJD toothache toothache cavity 0.04 0.06 cavity 0.01 0.89 Sum of all atomic events = 1 Cavity P(toothache|Cavity) P(toothache|Cavity) T 0.90 0.1 F 0.05 0.95 Sum of a row = 1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 55. 王元凱 Unit - Probability Review p. 55 More Than 2 Random Variables in Conditional Probability Joint conditional probability P( X1  X 2 | X 3  X 4 ) P( X1  X 2  X 3  X 4 )  P( X 3  X 4 )  P( X1 | X 2  X 3  X 4 )P( X 2 | X 3  X 4 ) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 56. 王元凱 Unit - Probability Review p. 56 Chain Rule • Joint probability can be calculated from a chain of conditional probability P( X | X )  P( X 1  X 2 ) 1 2 P( X 2 ) P( X 1  X 2 )  P( X 1 | X 2 ) P( X 2 ) P( X1  X 2  X 3  X 4 )  P( X1  ( X 2  X 3  X 4 ))  P( X1 | X 2  X 3  X 4 )P( X 2  X 3  X 4 )  P( X1 | X 2  X 3  X 4 )P( X 2 | X 3  X 4 )P( X 3 | X 4 )P( X 4 ) n P( X1  X 2  X n )   P( X i | X i 1  X n ) i 1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 57. 王元凱 Unit - Probability Review p. 57 Useful Easy-to-prove Facts P( A | B)P(A | B )  1 nA  P( A  v k 1 k | B)  1 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 58. 王元凱 Unit - Probability Review p. 58 Where Are We?  We have recalled the fundamentals of probability  We know what JDs are and how to use them  Next two sections  Bayes rule  Gaussian distribution Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 59. 王元凱 Unit - Probability Review p. 59 6. Bayes Theorem P ( A | B ) P ( A)  P ( B | A) P ( B ) P( A  B)  P( A | B) P( B)  P ( B  A)  P ( B | A) P ( A)  P ( A | B ) P ( B )  P ( B | A) P ( A) Bayes, Thomas (1763) An essay towards solving a problem in the doctrine of chances. Philosophical Transactions of the Royal Society of London, 53:370-418 Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 60. 王元凱 Unit - Probability Review p. 60 Useful Forms of Bayes Rule P( B | A) P( A) P( A  B) P( A | B)   P( B) P( B) P( B | A  C ) P( A  C ) P( A |B  C )  P( B  C ) P( B | A, C ) P( A, C ) P( B | A, C ) P( A | C ) P( A |B, C )   P ( B, C ) P( B | C ) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 61. 王元凱 Unit - Probability Review p. 61 More General Forms of Bayes Rule If A is a Boolean R.V. P( A  B) P( A  B) P( A |B)   P( B) P ( A  B )  P ( A  B ) If A is a discrete R.V. P( A  vi  B) P(B | A  vi )P( A  vi ) P( A  vi |B)  nA  nA P(A  v  B) P(B | A  v )P(A  v ) k 1 k k 1 k k Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 62. 王元凱 Unit - Probability Review p. 62 Example – Bayesian Detection (1/2)  2-class recognition  Ex.: Skin color detection  Let  A be skin color pixel  A be non-skin color pixel  c be the color (R,G,B) of a pixel  We can get : P(c|A), P(c|A)  For a pixel in a new image, is it a skin color pixel? P(c | A) P( A) P(c | A) P(A) P( A | c)  > P ( A | c )  P (c ) P (c ) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 63. 王元凱 Unit - Probability Review p. 63 Example – Bayesian Detection (2/2)  2-class recognition  Ex.: Background detection  Let  A be background pixel  A be non-background pixel  c be the color (R,G,B) of a pixel  We can get : P(c|A), P(c|A)  For a pixel in a new image, is it a background pixel? P(c | A) P( A) P(c | A) P(A) P( A | c)  > P ( A | c )  P (c ) P (c ) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 64. 王元凱 Unit - Probability Review p. 64 7. Summary Continuous variable Discrete variable (X has M values, Y has N values) P(X) Function of one variable M vector P(X=x) Scalar* Scalar P(X,Y) Function of two variables MxN matrix P(X|Y) Function of two variables MxN matrix P(X|Y=y) Function of one variable M vector P(X=x|Y) Function of one variable N vector P(X=x|Y=y) Scalar* Scalar Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 65. 王元凱 Unit - Probability Review p. 65 Ex (1/2) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 66. 王元凱 Unit - Probability Review p. 66 Ex (2/2) Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright
  • 67. 王元凱 Unit - Probability Review p. 67 8. Reference  Artificial Intelligence: a modern approach  Russell & Norvig, 2nd, Prentice Hall, 2003.  Sections 13.1~13.3, pp.462~474.  統計學的世界  墨爾著,鄭惟厚譯  天下文化,2002  深入淺出統計學  D. Grifiths, 楊仁和譯,2009  O’ Reilly Fu Jen University Department of Electrical Engineering Wang, Yuan-Kai Copyright