WebLab STEM

Mathematics · 6. Probability and statistics

From randomness to models, Bayes theorem and Markov chains

Construct sample spaces, Law of Total Probability & Bayes theorem, grouped data summary statistics, and discrete-time Markov chains with stationary distributions in real-world modeling.

40 minutesContent version: 2.1

Driving question

How does Bayes theorem update beliefs with new data, and how do Markov chains predict long-term equilibria?

Curriculum coverage

Vietnam Mathematics 6–12; Cambridge IGCSE/A-Level probability, Bayes and Markov chains.

Model scope and limitations

Pseudorandom simulation illustrates a model; one finite run does not prove a distribution or replace a statistical test.

Learning objectives

  • Construct a sample space and calculate basic, conditional and independent event probabilities.
  • Apply Law of Total Probability and Bayes theorem to update posterior probabilities in diagnosis and classification.
  • Compute grouped data summary statistics (median Me, quartiles Q1, Q3) and Pearson linear correlation r.
  • Set up Markov chain transition probability matrices and solve for stationary distribution π.

Prerequisite knowledge

  • Fractions, basic counting and reading tables/graphs.
  • Matrix multiplication and linear systems.

Core knowledge

Independence & Mutual exclusivity

A and B are independent when P(A∩B) = P(A)P(B). Mutually exclusive events have A∩B = ∅, so P(A∩B) = 0 and P(A∪B) = P(A) + P(B).

Law of Total Probability & Bayes theorem

1. Total probability: For a partition {A₁, ..., Aₙ}, P(B) = ∑ P(Aᵢ)P(B|Aᵢ). 2. Bayes theorem: P(Aₖ|B) = [P(Aₖ)P(B|Aₖ)] / P(B). Updates prior probability P(Aₖ) into posterior P(Aₖ|B) given evidence B. Fundamental to medical diagnostics, spam filters, and Naive Bayes ML.

Discrete Markov chains & Stationary distribution

Markov property: next state depends only on current state (P(X_{n+1}=j | X_n=i) = p_{ij}). Transition matrix P has row sums equal to 1. Stationary distribution π satisfies π·P = π and ∑ πᵢ = 1. Powers Google PageRank, population mobility models and weather forecasting.

Grouped data statistics & Regression

Grouped data gives median Me = um + ((n/2 − C)/nm)·h and quartiles Q1, Q3. Interquartile range ΔQ = Q3 − Q1 measures spread. Pearson correlation r (−1 ≤ r ≤ 1) assesses linear association between x and y.

Poisson distribution & Chebyshev inequality

Poisson distribution P(X = k) = λ^k·e^(−λ)/k! has E(X) = Var(X) = λ. Chebyshev’s inequality P(|X − μ| ≥ kσ) ≤ 1/k² bounds extreme deviations for any distribution.

Law of large numbers

As trials increase, relative frequency tends toward probability but need not approach monotonically.

Worked example

Example 1 (Bayes): A rare disease affects 0.1% of people (prior = 0.001). Test has 99% sensitivity and 98% specificity (false positive = 2%). If tested positive: P(Disease|+) = (0.001 × 0.99) / (0.001 × 0.99 + 0.999 × 0.02) ≈ 4.7% (Base Rate Fallacy). Example 2 (Markov): Transition P = [[0.8, 0.2], [0.4, 0.6]] yields stationary distribution π = (2/3, 1/3).

Misconceptions to avoid

  • Base Rate Fallacy: Confusing P(Positive|Disease) with P(Disease|Positive); for rare diseases, most positive tests are actually false positives.
  • In a Markov transition matrix P, each ROW sum must equal 1 (∑_j p_ij = 1), not each column.
  • After five tails, a fair coin still has P(head)=1/2; the past is not “owed” a correction.
  • Correlation does not prove causation; confounders can create association.

Virtual experiment procedure: Galton board and binomial distribution

  1. State the model, fairness/independence assumptions and predicted distribution before running.
  2. Run increasing sample sizes and save frequencies, not only the final picture.
  3. Compare frequency with probability using absolute deviation and explain variation.

Safety and cautions

  • Do not interpret small probability as impossible, or use an educational simulation for medical/financial decisions.

Evidence to collect

  • A sample-size/frequency table, distribution graph and comment on both trend and fluctuation.
Open the virtual experiment
📋 Embed this simulation in online lectures (For Teachers & LMS)

Copy the iframe code below to embed this interactive simulation into Canvas, Moodle, Google Sites or educational blogs:

<iframe src="https://visuallab.win/math-lab/?module=galton_board" width="100%" height="560" frameborder="0" allow="fullscreen" loading="lazy"></iframe>

Diagnostic check

1. For mutually exclusive A and B, P(A∩B)=?

  1. 0
  2. 1
  3. P(A)+P(B)
Show answer and explanation

Correct answer: 0

They cannot occur together.

2. Conditional probability P(A|B) equals?

  1. P(A∩B)/P(B)
  2. P(A)+P(B)
  3. P(B)/P(A∩B)
Show answer and explanation

Correct answer: P(A∩B)/P(B)

Restricting the sample space to B gives division by P(B).

3. What does Bayes theorem allow us to calculate?

  1. Posterior probability P(A|B) from prior P(A) and likelihood P(B|A)
  2. Probability of union P(A ∪ B)
  3. Expectation of random variable
Show answer and explanation

Correct answer: Posterior probability P(A|B) from prior P(A) and likelihood P(B|A)

Bayes theorem reverses conditions, updating prior probabilities into posterior ones given new evidence B.

4. What is the required normalization condition for a discrete Markov transition matrix P?

  1. Each row sum equals 1
  2. Each column sum equals 1
  3. Determinant det(P) = 1
Show answer and explanation

Correct answer: Each row sum equals 1

From any state i, the transition probabilities to all possible next states j must sum to 1, meaning each row sums to 1.

Application practice

1. By Chebyshev’s inequality, what is the maximum probability of deviating by 3 or more standard deviations (k = 3)?

  1. 1/9 (approx 11.1%)
  2. 5%
  3. 1/3 (approx 33.3%)
Show answer and explanation

Correct answer: 1/9 (approx 11.1%)

By Chebyshev’s inequality, P(|X − μ| ≥ 3σ) ≤ 1/3² = 1/9 ≈ 11.1% for any probability distribution.

2. If independent P(A)=0.4 and P(B)=0.5, P(A∩B)=?

  1. 0.2
  2. 0.9
  3. 0.45
Show answer and explanation

Correct answer: 0.2

For independence multiply: 0.4×0.5 = 0.2.

3. What does the interquartile range ΔQ = Q3 − Q1 measure in a sample?

  1. Spread of the middle 50% of data
  2. The overall sample mean
  3. The most frequent value
Show answer and explanation

Correct answer: Spread of the middle 50% of data

The interquartile range ΔQ = Q3 − Q1 measures the spread of the central 50% of data and is robust against outliers.

4. A 2-state Markov chain has transition matrix P = [[0.7, 0.3], [0.2, 0.8]]. What is its stationary distribution π = (π₁, π₂)?

  1. π = (0.4, 0.6)
  2. π = (0.5, 0.5)
  3. π = (0.7, 0.3)
Show answer and explanation

Correct answer: π = (0.4, 0.6)

Solving π₁ = 0.7π₁ + 0.2π₂ yields 3π₁ = 2π₂. Combining with π₁ + π₂ = 1 gives π₁ = 0.4 and π₂ = 0.6.

5. A factory has Machine 1 producing 60% of output (1% defect rate) and Machine 2 producing 40% (2% defect rate). A randomly chosen product is defective. What is the probability it was produced by Machine 1?

  1. 42.9% (3/7)
  2. 60%
  3. 50%
Show answer and explanation

Correct answer: 42.9% (3/7)

Total probability of defect: P(Defect) = 0.006 + 0.008 = 0.014. By Bayes: P(Machine 1 | Defect) = 0.006 / 0.014 = 3/7 ≈ 42.9%.

Academic references

  1. Cambridge IGCSE Mathematics 0580 — official syllabus and resources
  2. Cambridge AS & A Level Mathematics 9709 — official syllabus
  3. OpenStax Precalculus 2e — functions, geometry and probability

This lesson is maintained against the cited sources below. Simulations are learning models and do not replace supervised physical-laboratory safety procedures.

Content publisher
WebLab STEM
Technical maintainer
Đức Tiến — Control & Automation Engineer