Skip to content
PostBayesian Network / Lecture

Bayesian-01-Probability-Theory

2025-09-19
Back to Blog

Bayesian NetworkProbability Theory

Probability Space

  • Sample space Ω
    • a set of all possible outcomes of a random experiment.
  • Event
    • an event is a subset of the sample space Ω.
  • σ-algebra F on sample space:
    • a collection of events for which it makes sense to assign probability, satisfies
      • i. The empty set is in F;
      • ii. The union of any set in F is also in F;
      • iii. If a set S is in F, the complement Sc is also in F.
  • A measurable event
    • A measurable event SΩ is a subset of the sample space, to which we are willing to assign probability.
    • Sfemale={female students} is an event that the randomly selected student is female.
    • Number of events: 2|Ω| where |Ω| is the number of samples.
    • A measurable event that is an element of the σ-algebra satisfies these three basic properties:
      1. It contains empty event , or say is in the σ-algebra.
      2. [Closed under union] If α,β are measurable, then αβ is measurable. Or say, the union of these events is in the σ-algebra.
      3. [Closed under complementation] If S is measurable, then the complement Sc is also measurable.

Properties of Probability

Probability distribution

A Probability distribution P over (Ω,S) is a function mapping a measurable S to real values, satisfying the following conditions:

  1. P(α)0,αS. Probabilities are nonnegative.

  2. P(Ω)=1, trivial event: all possible outcomes have the maximal probability of 1.

  3. Additivity: If α,βS and are disjoint events αβ=, then

    P(αβ)=P(α)+P(β)

    The probability that one of the two mutually exclusive (disjoint) events will occur is the sum of the two, which also implies:

    P(αβ)=P()=0P(αβ)=P(α)+P(β)P(αβ)

Example: |Ω| be the number of all UIC students. We can define the probability measure:

P(Sfemale)=|Sfemale||Ω|

so P(Sfemale) is the fraction of female students in UIC.


Key properties:

  1. Monotonicity: If AB, then P(A)P(B).

  2. Intersection bound: P(AB)min(P(A),P(B)).

  3. Union bound: P(AB)P(A)+P(B).

  4. Complement rule: P(ΩA)=1P(A).

  5. Law of total probability: If A1,A2,,Ak are disjoint events such that i=1kAi=Ω, then:

    i=1kP(Ai)=1

A probability space (Ω,F,P) consists of:

  1. A sample space Ω;
  2. A σ-algebra F of measurable events;
  3. A probability measure P.

Random variable

Random variable: is defined by a function associated with each outcome ωΩ:


Discrete random variables:

  1. Categorical (or discrete), e.g. gender, faculty.
  2. The probability mass function of a random variable X:P(X):ΩX[0,1]Example:P(gender=f)=15
  3. P(x)=pX(x)=P(X=x) with properties:
    • 0pX(x)1
    • xApX(x)=P(XA) (countable unions of disjoint sets)
  • xΩpX(x)=P(Ω)=1

Continuous random variables:

  1. Values in a given range, e.g. height, weight.

  2. The probability density function (PDF): f(x)0, and:

    f(x)dx=1
  3. The cumulative distribution function (CDF):

    P(Xx)=F(x)=xf(x)dx

    Then we have F()=0 and F()=0.

    We have:

    P(aXb)=abf(x)dx=F(b)F(a)

    And note that:

    P(X=a)=0

    For continuous random variables, the probability at a point is zero.

Domain of a random variable ΩX:

Example: Ωgender={f,m}, Ωheight=(0,3).

For any state x of a random variable X, {ωΩX(ω)=x} is an event.

Multivariate probability

Multivariate Probability: Suppose there are two random variables X and Y.

(a) A joint probability mass function P(X,Y) over these random variables is

P(X=x,Y=y)

It describes the probability distribution of multiple variables together.

(b) Example: Students at university with random variables:

  1. Intelligence: low i0, high i1
  2. Scores: low s0, high s1

Example table of joint distribution P(I,S):

ISP(I,S)
i0s00.665
i0s10.035
i1s00.06
i1s10.24

Table 1: Joint distribution P(I,S).

The joint probability P(I,S) is given in the table below:

i. The joint distribution P(X,Y) contains information about all aspects of the relations among these 2 random variables.
ii. In theory, one can answer any query about relations among the variables based on the joint distribution.

(c) Marginal distribution P(X) is the sum of the joint distribution over a set of random variables:

P(X=x)=yP(X=x,Y=y)

It is obtained by summing out other variables from the joint distribution.

i. Query 1: Based on the joint distribution table, what is the probability of a randomly selected student being intelligent I=i1 (sum over s)?

P(i1)=P(i1,s0)+P(i1,s1)=0.06+0.24=0.3
Pi0i1P(S)
s00.6650.060.725
s10.0350.240.275
P(I)0.70.31

Table 2: Table with joint and marginal distribution.

ii. Query 2: What is the probability that a random student has received low scores S=s0?

P(s0)=n=01P(in,s0)=P(i0,s0)+P(i1,s0)=0.665+0.06=0.725

Conditional Probability

Conditional Probability: α is an event of non-zero probability, the conditional probability of any event β given α is defined as:

P(βα)=P(α,β)P(α)

So the joint distribution can also be written as by rearranging the conditional probability definition formula:

P(α,β)=P(α)P(βα)

(a) Query 3: What is the probability an intelligent student gets low scores? And what is the probability they get high scores?
Note that here intelligent student i1 is a condition. Based on this condition, we want to find out the chance for them to get high or low scores.

P(s0i1)=P(s0,i1)P(i1)=0.060.3=0.2P(s1i1)=P(s1,i1)P(i1)=0.240.3=0.8

Note that:

n=01P(sni1)=1

(b) Query 4: What is the probability a student got a high score is not intelligent?

P(i0s1)=P(s1,i0)P(s1)=0.060.2750.218

Marginal Independence

Marginal Independence: An event α is independent of event β if:

P(αβ)=P(α)

or

P(β)=0

Alternative definition: α and β are independent if and only if:

P(α,β)=P(α)P(β)

Intuitively, α and β are independent means that observing β does not have any effect on the probability of α.
For example: α: the first toss of a coin is head, β: the second toss of a coin is head.


(a) Query 5: Are intelligence and scores independent?

P(s0,i0)P(s0)P(i0)

Actually, P(S,I)P(S)P(I), so these two variables are NOT independent.
It means knowing the intelligence gives us some knowledge about their scores, and vice versa.

Bayes’ theorem, inverse conditional probability

P(αβ)=P(α,β)P(β)=P(α)P(βα)P(β)

because:

P(α,β)=P(α)P(βα)=P(β)P(αβ)

Example 1: Medical Testing
Suppose a disease affects 1% of the population. We also have a test for this disease that is 99% accurate.
This means that if a person has the disease, the test will be positive 99% of the time, and if a person does not have the disease, the test will be negative 99% of the time.
Now, if a person tests positive, what is the probability that they actually have the disease?

This is not immediately obvious because, although the test is 99% accurate, the disease only affects 1% of the population. We can use Bayes' Theorem to find out.


Solution

  • Let α be the event that the person has the disease, ¬α (or αc) is the complement (does not have the disease).
  • Let β be the event that the person tests positive, and ¬β (or βc) be the event that the person tests negative.

We want to find P(αβ). Now we know:

  1. Prior distribution: P(α)=0.01 (marginal probability of α), the probability that a person has the disease is 1%.
  2. P(¬α)=0.99
  3. P(βα)=0.99 (conditional probability): The probability that the person tests positive given that they have the disease is 0.99 (because the test is 99% accurate).
  4. P(β¬α)=0.01

Joint Probabilities:

  • P(β,α)=P(βα)P(α)=0.99×0.01=0.0099
  • P(β,¬α)=P(β¬α)P(¬α)=0.01×0.99=0.0099

Marginal Probability P(β):

  • P(β)=P(β,α)+P(β,¬α)
  • P(β)=0.0099+0.0099=0.0198

Posterior Distribution:

Finally, substitute into Bayes' theorem to find the posterior distribution:

P(αβ)=P(β,α)P(β)=P(α)P(βα)P(β)=0.99×0.010.99×0.01+0.01×0.99=0.5

Although the test is 99% accurate, a person who tests positive β only has a 50% chance of actually having the disease. This is because the disease is so rare (P(α)=0.01 in the population).

Chain Rule

P(α,β)=P(α)P(βα)P(α,β,γ)=P(α)P(βα)P(γα,β)

This is how we compute the joint probability. And it is the direct result of conditional probability.


P(βα)=P(α,β)P(α)

and

P(γα,β)=P(α,β,γ)P(α,β)=P(α,β,γ)P(α)P(βα)

If α and β are independent, we have:

P(α,β)=P(α)P(β)

which means:

P(βα)=P(β)

Conditional Independence

(a) Two events X and Y are conditionally independent given Z if:

P(XY,Z)=P(XZ)

Then X is conditionally independent of Y given Z, written as:

(XYZ)

Meaning:

(b) If we know Z already, knowing Y does not give us additional information about X.

(c) Y might contain some information about X, but all this information is also contained in Z.


(d) Symmetry:
If (XYZ), then:

(YXZ)

(e) Equivalent definition

P(X,Y|Z)=P(X|Z)P(Y|Z)

Proposition

Proposition: (XYZ) if and only if one of the following conditions hold:

(a)

P(XY,Z)=P(XZ)

(b)

P(X,YZ)=P(XZ)P(YZ)

(c)

P(X,Y,Z)=P(XZ)P(YZ)P(Z)ifP(Z)>0

Exercise:

i. (a) (b) given and using the chain rule:

P(XY,Z)=P(X,Y,Z)P(Y,Z)

Expanding using the chain rule:

P(XY,Z)=P(X,YZ)P(Z)P(YZ)P(Z)

Simplify the equation:

P(XY,Z)=P(X,YZ)P(YZ)=P(XZ)

So, rearranging this equation, we have (b).

ii. (a) (c) given and using the chain rule:

P(XY,Z)=P(X,YZ)P(YZ)=P(X,Y,Z)P(Y,Z)=P(XZ)P(X,Y,Z)=P(Y,Z)P(XZ)P(X,Y,Z)=P(XZ)P(YZ)P(Z)

Expectation

Expectation

(a) Expectations: weighted average of discrete variables

Ep[X]=xval(X)xP(X=x)

(b) Properties:
i. Constant E[a]=a
ii. Linearity of expectation:

E[X+Y]=E[X]+E[Y]E[aX]=aE[X]

(c) Products of two variables:
i. If X and Y are independent, then

E[XY]=E[X]E[Y]

(d) Conditional expectation

Ep[Xy]=xxP(xy)

Variance

Variance: a measure of how concentrated the distribution of X is around its mean.

(a) A variance is defined as

varp[X]=E[(XE[X])2]

or

varp[X]=E[X2](E[X])2

This is a very useful formula to compute the variance. Try to derive this using the properties of expectations!

(b) Properties:
i. Constant

var[a]=0

ii. Quadratic scale

var[aX]=a2var[X]

iii. If X and Y are independent, then

var[X+Y]=var[X]+var[Y]

(c) Standard deviation

σX=var[X]

a normalized measure of distance from the expectation.

Discrete Random Variables

(a) Bernoulli trials: XBernoulli(p) where 0p1, the outcome of a single trial, e.g., flip a coin (H=1,T=0) comes up heads with probability p

P(x)={px=11px=0
  • 期望 (Mean): E[X]=p
  • 方差 (Variance): Var[X]=p(1p)

(b) Binomial distribution: XBinomial(n,p): X is the number of heads in n independent flips with heads probability p,

P(X=k)=(nk)pk(1p)nk

k is the number of successes in n independent trials.

  • 期望 (Mean): E[X]=np
  • 方差 (Variance): Var[X]=np(1p)

(c) Multinomial distribution: X=(X1,X2,...,Xk) represents the number of outcomes in each of k categories in n independent trials, where the probability of outcome i is pi

P(X=x)=n!x1!x2!xk!p1x1p2x2pkxk

with

i=1kxi=n,i=1kpi=1
  • 期望 (Mean): E[Xi]=npi (其中 Xi 是第 i 个类别中的事件数量)
  • 方差 (Variance): Var[Xi]=npi(1pi)
  • 协方差 (Covariance): Cov(Xi,Xj)=npipj (其中 i!=j,表示不同类别之间的协方差)