8.1 Probability

8.1.3 Conditional Probability

Probability is a measure of belief. Beliefs need to be updated when new evidence is observed.

The measure of belief in proposition h given proposition e is called the conditional probability of h given e, written P(he).

A proposition e representing the conjunction of all of the agent’s observations of the world is called evidence. Given evidence e, the conditional probability P(he) is the agent’s posterior probability of h. The probability P(h) is the prior probability of h and is the same as P(htrue) because it is the probability before the agent has observed anything.

The evidence used for the posterior probability is everything the agent observes about a particular situation. Everything observed, and not just a few select observations, must be conditioned on to obtain the correct posterior probability.

Example 8.3.

For the diagnostic assistant, the prior probability distribution over possible diseases is used before the diagnostic agent finds out about the particular patient. Evidence is obtained through discussions with the patient, observing symptoms, and the results of lab tests. Essentially any information that the diagnostic assistant finds out about the patient is evidence. The assistant updates its probability to reflect the new evidence in order to make informed decisions.

Example 8.4.

The information that the delivery robot receives from its sensors is its evidence. When sensors are noisy, the evidence is what is known, such as the particular pattern received by the sensor, not that there is a person in front of the robot. The robot could be mistaken about what is in the world but it knows what information it received.

Semantics of Conditional Probability

Evidence e, where e is a proposition, will rule out all possible worlds that are incompatible with e. Like the definition of logical consequence, the given proposition e selects the possible worlds in which e is true. As in the definition of probability, we first define the conditional probability over worlds, and then use this to define a probability over propositions.

Evidence e induces a new probability P(we) of world w given e. Any world where e is false has conditional probability 0, and the remaining worlds are normalized so that the probabilities of the worlds sum to 1:

P(we)={c*P(w) if e is true in world w0 if e is false in world w

where c is a constant (that depends on e) that ensures the posterior probability of all worlds sums to 1.

For P(we) to be a probability measure over worlds for each e:

1 =wP(we)
=w:e is true in wP(we)+w:e is false in wP(we)
=w:e is true in wc*P(w)+0

Therefore, c=1/P(e). Thus, the conditional probability is only defined if P(e)>0. This is reasonable, as if P(e)=0, e is impossible.

The conditional probability of proposition h given evidence e is the sum of the conditional probabilities of the possible worlds in which h is true. That is,

P(he)= w:h is true in wP(we)
= w:he is true in wP(we)+w:¬he is true in wP(we)
= w:he is true in w1P(e)*P(w)+0
= P(he)P(e).

The last form above is typically given as the definition of conditional probability. Here we have derived it as a consequence of a more basic definition.

Example 8.5.

As in Example 8.2, consider the worlds of Figure 8.1, each with probability 0.1. Given the evidence Filled=false, only 4 worlds have a non-zero posterior probability. P(Shape=circleFilled=false)=0.25 and P(Shape=starFilled=false)=0.5.

A conditional probability distribution, written P(XY) where X and Y are variables or sets of variables, is a function of the variables: given a value xdomain(X) for X and a value ydomain(Y) for Y, it gives the value P(X=xY=y), where the latter is the conditional probability of the propositions.

Background Knowledge and Observation

The difference between background knowledge and observation was described in Section 5.4.1. When reasoning with uncertainty, the background model is described in terms of a probabilistic model, and the observations form evidence that must be conditioned on.

Within probability, there are two ways to state that a is true:

  • The first is to state that the probability of a is 1 by writing P(a)=1.

  • The second is to condition on a, which involves using a on the right-hand side of the conditional bar, as in P(a).

The first method states that a is true in all possible worlds. The second says that the agent is only interested in worlds where a happens to be true.

Suppose an agent was told about a particular animal:

P(fliesbird) =0.8,
P(birdemu) =1.0,
P(fliesemu) =0.001.

If the agent determines the animal is an emu, it cannot add the statement P(emu)=1. No probability distribution satisfies these four assertions. If emu were true in all possible worlds, it would not be the case that in 0.8 of the possible worlds, the individual flies. The agent, instead, must condition on the fact that the individual is an emu.

To build a probability model, a knowledge base designer takes some knowledge into consideration and builds a probability model based on this knowledge. All knowledge acquired subsequently must be treated as observations that are conditioned on.

Suppose proposition k represents an agent’s observations up to some time. The agent’s subsequent belief states can be modeled by either of the following:

  • construct a probability model for the agent’s belief before it had observed k and then condition on the evidence k conjoined with the subsequent evidence e (i.e, for each proposition α use P(αek))

  • construct a probability model, call it Pk, which models the agent’s beliefs after observing k, and then condition on subsequent evidence e (i.e., use Pk(αe) for proposition α).

All subsequent probabilities will be identical no matter which construction was used. Building Pk directly is sometimes easier because the model does not have to cover the cases of when k is false. Sometimes, however, it is easier to build P and condition on k.

What is important is that there is a coherent stage where the probability model is reasonable and every subsequent observation is conditioned on.

The definition of conditional probability allows the decomposition of a conjunction into a product of conditional probabilities:

Proposition 8.3.

(Chain rule) For any propositions α1,,αn:

P(α1α2αn)= P(α1)*
= i=1nP(αiα1αi-1),

where the right-hand side is assumed to be zero if any of the products are zero (even if some of them are undefined).

Note that any theorem about unconditional probabilities can be converted into a theorem about conditional probabilities by adding the same evidence to each probability. This is because the conditional probability measure is a probability measure. For example, case (e) of Proposition 8.2 implies P(αβk)=P(αk)+P(βk)-P(αβk).

Bayes’ Rule

An agent using probability updates its belief when it observes new evidence. A new piece of evidence is conjoined to the old evidence to form the complete set of evidence. Bayes’ rule specifies how an agent should update its belief in a proposition based on a new piece of evidence.

Suppose an agent has a current belief in proposition h based on evidence k already observed, given by P(hk), and subsequently observes e. Its new belief in h is P(hek). Bayes’ rule tells us how to update the agent’s belief in hypothesis h as new evidence arrives.

Proposition 8.4.

(Bayes’ rule) As long as P(ek)0,


This is often written with the background knowledge k implicit. In this case, if P(e)0, then


P(eh) is the likelihood and P(h) is the prior probability of the hypothesis h. Bayes’ rule states that the posterior probability is proportional to the likelihood times the prior.


The commutativity of conjunction means that he is equivalent to eh, and so they have the same probability given k. Using the rule for multiplication in two different ways,

P(hek) =P(hek)*P(ek)
=P(ehk) =P(ehk)*P(hk).

The theorem follows from dividing the right-hand sides by P(ek), which is not 0 by assumption. ∎

Often, Bayes’ rule is used to compare various hypotheses (different his). The denominator P(ek) is a constant that does not depend on the particular hypothesis, and so when comparing the relative posterior probabilities of hypotheses, the denominator can be ignored.

To derive the posterior probability, the denominator may be computed by reasoning by cases. If H is an exclusive and covering set of propositions representing all possible hypotheses, then

P(ek) =hHP(ehk)

Thus, the denominator of Bayes’ rule is obtained by summing the numerators for all the hypotheses. When the hypothesis space is large, computing the denominator is computationally difficult.

Generally, one of P(ehk) or P(hek) is much easier to estimate than the other. Bayes’ rule is used to compute one from the other.

Example 8.6.

In medical diagnosis, the doctor observes a patient’s symptoms, and would like to know the likely diseases. Thus the doctor would like P(DiseaseSymptoms). This is difficult to assess as it depends on the context (e.g., some diseases are more prevalent in hospitals). It is typically more easy to assess P(SymtomsDisease) as how the disease gives rise to the symptoms is typically less context dependent. These two are related by Bayes’ rule, where the prior probability of the disease, P(Disease), reflects the context.

Example 8.7.

The diagnostic assistant may need to know whether the light switch s1 of Figure 1.8 is broken or not. You would expect that the electrician who installed the light switch in the past would not know if it is broken now, but would be able to specify how the output of a switch is a function of whether there is power coming into the switch, the switch position, and the status of the switch (whether it is working, shorted, installed upside-down, etc.). The prior probability for the switch being broken depends on the maker of the switch and how old it is. Bayes’ rule lets an agent infer the status of the switch given the prior and the evidence.

Example 8.8.

Suppose an agent has information about the reliability of fire alarms. It may know how likely it is that an alarm will work if there is a fire. To determine the probability that there is a fire, given that there is an alarm, Bayes’ rule gives:

P(firealarm) =P(alarmfire)*P(fire)P(alarm)

where P(alarmfire) is the probability that the alarm worked, assuming that there was a fire. It is a measure of the alarm’s reliability. The expression P(fire) is the probability of a fire given no other information. It is a measure of how fire-prone the building is. P(alarm) is the probability of the alarm sounding, given no other information. P(firealarm) is more difficult to directly represent because it depends, for example, on how much vandalism there is in the neighborhood.

Other Possible Measures of Belief

Justifying other measures of belief is problematic. Consider, for example, the proposal that the belief in αβ is some function of the belief in α and the belief in β. Such a measure of belief is called compositional. To see why this is not sensible, consider the single toss of a fair coin. Compare the case where α is “the coin will land heads”, β1 is “the coin will land tails” and β2 is “the coin will land heads.” The belief in β1 would be the same as the belief in β2. But the belief in αβ1, which is impossible, is very different from the belief in αβ2, which is the same as α.

The conditional probability P(fe) is very different from the probability of the implication P(ef). The latter is the same as P(¬ef), which is the measure of the interpretations for which f is true or e is false. For example, suppose there is a domain where birds are relatively rare, and non-flying birds are a small proportion of the birds. Here P(¬fliesbird) would be the proportion of birds that do not fly, which would be low. P(bird¬flies) is the same as P(¬bird¬flies), which would be dominated by non-birds and so would be high. Similarly, P(birdflies) would also be high, the probability also being dominated by the non-birds. It is difficult to imagine a situation where the probability of an implication is the kind of knowledge that is appropriate or useful.