AI-C01-BANK-001

AI Question Bank · Series 1 — Solved

Mathematical and Statistical Foundation of Data Science
PGD01C01
Self-paced practice
600 marks
Solved

AI-generated practice bank for PGD01C01 — 100 Part A (2 marks) + 20 Part B (20 marks) questions covering all five modules, fully solved in a simple exam-oriented style. Click any question to reveal the answer.

How to use this bank

Click a question to reveal its answer. Each question matches the exam style of the Calicut PGDDSA paper — short crisp answers for 2-mark questions, full statements + derivations + worked examples for 20-mark questions.

Coverage. 20 Part-A + 4 Part-B per module × 5 modules.

ModuleTopic
1Set theory, relations, combinatorics
2Graph theory
3Linear algebra
4Vectors & geometry of space
5Probability theory

PART A — Short Answer (2 marks each) · 100 questions

Module 1 — Set Theory, Relations, Combinatorics

A set is a well-defined collection of distinct objects called elements. Example: A={1,2,3,4}A = \{1, 2, 3, 4\} — the set of positive integers less than 5.

The power set is the set of all subsets of AA. If A=n|A| = n, then P(A)=2n|\mathcal{P}(A)| = 2^n. For A=4|A| = 4: P(A)=24=16|\mathcal{P}(A)| = 2^4 = 16.

AB=A+BAB|A \cup B| = |A| + |B| - |A \cap B|. We add both and subtract the overlap counted twice.

A binary relation that is reflexive (aaa \sim a), symmetric (abbaa \sim b \Rightarrow b \sim a), and transitive (ab,bcaca \sim b, b \sim c \Rightarrow a \sim c).

A partition of AA is a collection of non-empty, pairwise-disjoint subsets whose union is AA. Every equivalence relation creates a partition.

A set in bijection with N\mathbb{N} (countably infinite). Examples: N,Z,Q\mathbb{N}, \mathbb{Z}, \mathbb{Q}. Note: R\mathbb{R} is uncountable.

For any set AA, A<P(A)|A| < |\mathcal{P}(A)|. No set is in bijection with its own power set; hence R\mathbb{R} is uncountable.

A relation that is reflexive, antisymmetric (ab,baa=ba \le b, b \le a \Rightarrow a = b) and transitive. Example: divisibility on N\mathbb{N}.

8P3=8!(83)!=876=336^8P_3 = \dfrac{8!}{(8-3)!} = 8 \cdot 7 \cdot 6 = 336.

(103)=10!3!7!=10986=120\binom{10}{3} = \dfrac{10!}{3! \, 7!} = \dfrac{10 \cdot 9 \cdot 8}{6} = 120.

Letters: S×3, T×3, A×1, I×2, C×1 (total 10). Arrangements =10!3!3!2!=50,400= \dfrac{10!}{3! \, 3! \, 2!} = 50{,}400.

Circular arrangements =(81)!=7!=5040= (8 - 1)! = 7! = 5040. Fix one person and arrange the rest.

AB={1,2,3,4,5}A \cup B = \{1, 2, 3, 4, 5\}. AB={3}A \cap B = \{3\}.

(AB)c=AcBc(A \cup B)^c = A^c \cap B^c and (AB)c=AcBc(A \cap B)^c = A^c \cup B^c. The complement of union = intersection of complements.

A×B={(a,b):aA,bB}A \times B = \{(a, b) : a \in A, b \in B\} — set of all ordered pairs. A×B=AB|A \times B| = |A| \cdot |B|.

A relation RR on AA is reflexive if aRaa R a for every aAa \in A. Example: \le on R\mathbb{R} (every number is \le itself).

aRbbRaa R b \Rightarrow b R a for all a,ba, b. Example: "is a sibling of" — if A is sibling of B, then B is sibling of A.

aRba R b and bRcaRcb R c \Rightarrow a R c. Example: "is taller than" — if A is taller than B and B taller than C, then A is taller than C.

If (i) P(1)P(1) is true and (ii) P(k)P(k+1)P(k) \Rightarrow P(k+1) for all k1k \ge 1, then P(n)P(n) is true for all natural numbers nn.

(53)=5!3!2!=10\binom{5}{3} = \dfrac{5!}{3! \, 2!} = 10 such subsets.

nPn=n!(nn)!=n!0!=n!^n P_n = \dfrac{n!}{(n - n)!} = \dfrac{n!}{0!} = n! — the number of ways to arrange all nn distinct objects.

nC0=1^n C_0 = 1 (empty selection) and nCn=1^n C_n = 1 (the full set). Both equal 1.

(nr)=(n1r1)+(n1r)\binom{n}{r} = \binom{n-1}{r-1} + \binom{n-1}{r}. Choosing rr from nn = choosing (r1)(r-1) that include a fixed element + rr that exclude it.

(nr)=n!r!(nr)!=n!(nr)!r!=(nnr)\binom{n}{r} = \dfrac{n!}{r! (n-r)!} = \dfrac{n!}{(n-r)! r!} = \binom{n}{n-r}. Picking rr to include = picking (nr)(n-r) to exclude.

=2n= 2^n. (By Binomial theorem with x=y=1x = y = 1.) This equals the total number of subsets of an nn-element set.

11 letters: E×3, N×3, G×2, I×2, R×1. Arrangements =11!3!3!2!2!=39,916,800144=277,200= \dfrac{11!}{3! \, 3! \, 2! \, 2!} = \dfrac{39{,}916{,}800}{144} = 277{,}200.

Arrange 5 boys: 5!=1205! = 120. This creates 6 gaps (before, between, after). Choose 4 of 6 gaps for the girls and arrange them: (64)4!=1524=360\binom{6}{4} \cdot 4! = 15 \cdot 24 = 360. Total =120×360=43,200= 120 \times 360 = 43{,}200.

Pick 4 of 5 digits and arrange: 5P4=5!1!=120^5 P_4 = \dfrac{5!}{1!} = 120 four-digit numbers.

Each of the 4 positions has 26 choices independently: 264=456,97626^4 = 456{,}976 words.

(1511)=(154)=151413124!=32,76024=1365\binom{15}{11} = \binom{15}{4} = \dfrac{15 \cdot 14 \cdot 13 \cdot 12}{4!} = \dfrac{32{,}760}{24} = 1365 ways.

Two specific books are pre-selected. Choose remaining 2 from the other 8: (82)=28\binom{8}{2} = 28 ways.

Necklace arrangements (rotations + reflections equivalent): (n1)!2=4!2=12\dfrac{(n - 1)!}{2} = \dfrac{4!}{2} = 12 arrangements.

"EQUATION" has 8 letters, 5 vowels (E, U, A, I, O) and 3 consonants (Q, T, N). Treat the 5 vowels as one block: 4 units to arrange = 4!4!. Vowels inside the block: 5!5!. Total =4!×5!=24×120=2880= 4! \times 5! = 24 \times 120 = 2880.

Stars and bars: (n+k1k1)=(10+3131)=(122)=66\binom{n + k - 1}{k - 1} = \binom{10 + 3 - 1}{3 - 1} = \binom{12}{2} = 66 ways.

Total committees of 5 from 14: (145)=2002\binom{14}{5} = 2002. Subtract committees with fewer than 2 women — i.e., 0 women or 1 woman:

  • 0 women: (85)=56\binom{8}{5} = 56.
  • 1 woman: (61)(84)=670=420\binom{6}{1} \binom{8}{4} = 6 \cdot 70 = 420.

Answer =200256420=1526= 2002 - 56 - 420 = 1526 ways.

Module 2 — Graph Theory

A graph G=(V,E)G = (V, E) with no self-loops and no multiple edges between the same pair of vertices.

A graph that allows multiple edges between the same pair of vertices, but typically no self-loops.

vVdeg(v)=2E\sum_{v \in V} \deg(v) = 2|E|. Each edge contributes 1 to the degree of each endpoint, so the sum is twice the edge count.

E=(n2)=n(n1)2|E| = \binom{n}{2} = \dfrac{n(n-1)}{2} — every pair of vertices joined.

E=mn|E| = m \cdot n — every vertex on the left joined to every vertex on the right.

A closed walk that uses every edge exactly once. A connected graph has one iff every vertex has even degree (Euler's theorem).

A cycle that visits every vertex of the graph exactly once. Finding one is NP-complete in general.

A path is a sequence of distinct vertices joined by edges; first and last differ. A cycle is a closed path (first vertex = last vertex).

VE+F=2V - E + F = 2, where FF counts all faces including the unbounded outer face.

For simple planar graphs E3V6E \le 3V - 6. For K5K_5: V=5,E=10V = 5, E = 10, but 3(5)6=9<103(5) - 6 = 9 < 10. So K5K_5 cannot be planar.

A subgraph of a connected graph GG that is a tree and includes every vertex of GG. It has V1|V| - 1 edges.

Exactly n1n - 1. A tree is connected and acyclic, with this minimum number of edges to connect all vertices.

For nn vertices, the n×nn \times n matrix AA where Aij=1A_{ij} = 1 if (vi,vj)E(v_i, v_j) \in E and 0 otherwise. Symmetric for undirected graphs.

The number of walks of length exactly kk from vertex viv_i to vertex vjv_j.

A graph where each edge has a direction (ordered pair). Each vertex has separate in-degree and out-degree.

In-degree of a vertex = number of edges coming into it. Out-degree = number of edges going out from it.

A graph is connected if there is a path between every pair of vertices. Otherwise, it splits into connected components.

A graph whose vertex set splits into two disjoint subsets V1,V2V_1, V_2 such that every edge connects V1V_1 to V2V_2. No odd cycles.

A vertex whose removal disconnects the graph (or increases the number of components).

An edge whose removal disconnects the graph (or increases components). Removing it breaks a connected graph.

Module 3 — Linear Algebra

The rank is the number of linearly independent rows (equivalently, columns). It equals the dimension of the column space.

For an m×nm \times n matrix AA: rank(A)+nullity(A)=n\text{rank}(A) + \text{nullity}(A) = n.

Diagonal matrix — eigenvalues are the diagonal entries: λ1=2,λ2=3\lambda_1 = 2, \lambda_2 = 3.

A non-zero vector vv such that Av=λvA v = \lambda v for some scalar λ\lambda (the eigenvalue). AA only stretches vv — doesn't rotate it.

Trace = sum of diagonal entries: tr(A)=iaii\text{tr}(A) = \sum_i a_{ii}. Equals the sum of all eigenvalues.

A square matrix with det(A)=0\det(A) = 0 — it has no inverse, its columns are linearly dependent, and 0 is an eigenvalue.

Any real m×nm \times n matrix can be written A=UΣVTA = U \Sigma V^T, where UU and VV are orthogonal and Σ\Sigma is diagonal with non-negative singular values.

A square matrix QQ with QTQ=IQ^T Q = I — its columns (and rows) form an orthonormal set. detQ=±1\det Q = \pm 1.

cosθ=xyxy\cos\theta = \dfrac{x \cdot y}{\|x\| \, \|y\|} — measures the angle between two vectors. Used in text and embedding similarity.

The set {xRn:wTx+b=0}\{x \in \mathbb{R}^n : w^T x + b = 0\} for some non-zero ww. It's an (n1)(n-1)-dimensional flat. In 2D it's a line; in 3D a plane.

N(A)={x:Ax=0}N(A) = \{x : A x = 0\} — the set of vectors mapped to zero. Its dimension is the nullity.

Vectors v1,,vkv_1, \dots, v_k are linearly independent if c1v1++ckvk=0c_1 v_1 + \dots + c_k v_k = 0 implies all ci=0c_i = 0.

Every square matrix satisfies its own characteristic equation: if p(λ)=det(λIA)p(\lambda) = \det(\lambda I - A), then p(A)=0p(A) = 0.

det=(1)(4)(2)(3)=46=2\det = (1)(4) - (2)(3) = 4 - 6 = -2.

A square matrix with 1's on the diagonal and 0's elsewhere; InI_n acts as identity for matrix multiplication: AI=IA=AA I = I A = A.

For square AA with detA0\det A \ne 0, the inverse A1A^{-1} satisfies AA1=A1A=IA A^{-1} = A^{-1} A = I. For 2×22 \times 2: A1=1detA(dbca)A^{-1} = \dfrac{1}{\det A}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}.

A square matrix with AT=AA^T = A, i.e., aij=ajia_{ij} = a_{ji}. Always has real eigenvalues and orthogonal eigenvectors.

A symmetric matrix AA with xTAx>0x^T A x > 0 for all non-zero xx. All eigenvalues positive.

xyxy|x \cdot y| \le \|x\| \, \|y\| — the inner product is bounded by the product of norms.

Dropping a perpendicular from a vector onto a subspace. For vector uu onto vv: projvu=uvvvv\text{proj}_v u = \dfrac{u \cdot v}{v \cdot v} \, v.

Module 4 — Vectors and Geometry of Space

The vector OP\vec{OP} from origin OO to a point PP. For P(x,y,z)P(x, y, z), OP=x,y,z\vec{OP} = \langle x, y, z \rangle.

v=9+16+144=169=13\|\vec{v}\| = \sqrt{9 + 16 + 144} = \sqrt{169} = 13.

(1)(4)+(2)(5)+(3)(6)=4+10+18=32(1)(4) + (2)(5) + (3)(6) = 4 + 10 + 18 = 32.

a×b=i^j^k^a1a2a3b1b2b3\vec{a} \times \vec{b} = \begin{vmatrix} \hat i & \hat j & \hat k \\ a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \end{vmatrix}. Magnitude = absinθ\|\vec{a}\|\|\vec{b}\|\sin\theta = area of parallelogram.

r(t)=A+t(BA)\vec{r}(t) = \vec{A} + t(\vec{B} - \vec{A}) for tRt \in \mathbb{R}. Direction = BA\vec{B} - \vec{A}.

n(rr0)=0\vec{n} \cdot (\vec{r} - \vec{r}_0) = 0, where n\vec{n} is the normal and r0\vec{r}_0 is a point on the plane.

For plane ax+by+cz+d=0ax + by + cz + d = 0 and point P0(x0,y0,z0)P_0(x_0, y_0, z_0): d=ax0+by0+cz0+da2+b2+c2d = \dfrac{|a x_0 + b y_0 + c z_0 + d|}{\sqrt{a^2 + b^2 + c^2}}.

For line through AA with direction d\vec{d} and point PP: d=AP×ddd = \dfrac{\|\vec{AP} \times \vec{d}\|}{\|\vec{d}\|}.

(xh)2+(yk)2+(zl)2=r2(x - h)^2 + (y - k)^2 + (z - l)^2 = r^2 — sphere of radius rr centred at (h,k,l)(h, k, l).

x=rcosθx = r \cos\theta, y=rsinθy = r \sin\theta, z=zz = z.

x=ρsinϕcosθx = \rho \sin\phi \cos\theta, y=ρsinϕsinθy = \rho \sin\phi \sin\theta, z=ρcosϕz = \rho \cos\phi.

cosθ=abab\cos\theta = \dfrac{\vec{a} \cdot \vec{b}}{\|\vec{a}\| \, \|\vec{b}\|}. Take arccos\arccos for the angle.

projvu=uvvvv\text{proj}_{\vec{v}} \vec{u} = \dfrac{\vec{u} \cdot \vec{v}}{\vec{v} \cdot \vec{v}} \, \vec{v}.

[a,b,c]=a(b×c)[\vec{a}, \vec{b}, \vec{c}] = \vec{a} \cdot (\vec{b} \times \vec{c}) — a scalar equal to the (signed) volume of the parallelepiped with edges a,b,c\vec{a}, \vec{b}, \vec{c}.

V=a(b×c)V = |\vec{a} \cdot (\vec{b} \times \vec{c})| — absolute value of the scalar triple product.

Find two edge vectors from one point, compute their cross product (gives normal n\vec{n}), then use n(rr0)=0\vec{n} \cdot (\vec{r} - \vec{r}_0) = 0.

x=x0+at,  y=y0+bt,  z=z0+ctx = x_0 + a t, \; y = y_0 + b t, \; z = z_0 + c t, where (x0,y0,z0)(x_0, y_0, z_0) is a point on the line and (a,b,c)(a, b, c) its direction.

d=d1d2a2+b2+c2d = \dfrac{|d_1 - d_2|}{\sqrt{a^2 + b^2 + c^2}}.

(3,4,0)=5\|(3, 4, 0)\| = 5. Unit vector =(3/5,4/5,0)= (3/5, 4/5, 0).

(2,1,2)=3\|(2,1,2)\| = 3. Direction cosines: (2/3,1/3,2/3)(2/3, 1/3, 2/3).

Module 5 — Probability Theory

(i) P(A)0P(A) \ge 0. (ii) P(Ω)=1P(\Omega) = 1. (iii) For disjoint events, P(Ai)=P(Ai)P(\bigcup A_i) = \sum P(A_i).

P(AB)=P(AB)P(B)P(A \mid B) = \dfrac{P(A \cap B)}{P(B)} for P(B)>0P(B) > 0. "Probability of AA given BB has occurred."

P(AB)=P(BA)P(A)P(B)P(A \mid B) = \dfrac{P(B \mid A) \, P(A)}{P(B)}. Inverts conditioning using prior and likelihood.

AA and BB are independent iff P(AB)=P(A)P(B)P(A \cap B) = P(A) \, P(B). Knowing BB doesn't change P(A)P(A).

A function X:ΩRX: \Omega \to \mathbb{R} taking countably many values, described by PMF p(x)=P(X=x)p(x) = P(X = x) with p(x)=1\sum p(x) = 1.

A function taking values in an interval, described by PDF f(x)0f(x) \ge 0 with f=1\int f = 1. Probabilities = abf(x)dx\int_a^b f(x) dx.

P(X=k)=(nk)pk(1p)nk,  k=0,1,,nP(X = k) = \binom{n}{k} p^k (1-p)^{n-k}, \; k = 0, 1, \dots, n. Mean = npnp, variance = np(1p)np(1-p).

f(x)=1σ2πexp ⁣((xμ)22σ2)f(x) = \dfrac{1}{\sigma \sqrt{2\pi}} \exp\!\left(-\dfrac{(x - \mu)^2}{2 \sigma^2}\right) for xRx \in \mathbb{R}.

Mean =E[X]=p= E[X] = p. Variance =E[X2](E[X])2=pp2=p(1p)= E[X^2] - (E[X])^2 = p - p^2 = p(1-p).

E[X]=E[E[XY]]E[X] = E[E[X \mid Y]]. Average the conditional means over YY.

Cov(X,Y)=E[(XμX)(YμY)]=E[XY]E[X]E[Y]\text{Cov}(X, Y) = E[(X - \mu_X)(Y - \mu_Y)] = E[XY] - E[X] E[Y]. Measures linear co-movement.

P(X=k)=eλλkk!,  k=0,1,2,P(X = k) = \dfrac{e^{-\lambda} \lambda^k}{k!}, \; k = 0, 1, 2, \dots Mean = variance = λ\lambda.

f(x)=1baf(x) = \dfrac{1}{b - a} for x[a,b]x \in [a, b], else 0. Mean = (a+b)/2(a+b)/2, variance = (ba)2/12(b-a)^2/12.

f(x)=λeλxf(x) = \lambda e^{-\lambda x} for x0x \ge 0. Mean = 1/λ1/\lambda, variance = 1/λ21/\lambda^2.

For any random variable with finite variance: P(Xμkσ)1k2P(|X - \mu| \ge k \sigma) \le \dfrac{1}{k^2}.

F(x)=P(Xx)F(x) = P(X \le x). Non-decreasing, right-continuous, F()=0,F()=1F(-\infty) = 0, F(\infty) = 1.

Mean = λ\lambda, variance = λ\lambda. The Poisson is the only standard distribution where mean = variance.

Mean = a+b2\dfrac{a+b}{2}. Variance = (ba)212\dfrac{(b-a)^2}{12}.

If {B1,,Bn}\{B_1, \dots, B_n\} partitions Ω\Omega, then P(A)=iP(ABi)P(Bi)P(A) = \sum_i P(A \mid B_i) P(B_i).

ρ=Cov(X,Y)σXσY[1,1]\rho = \dfrac{\text{Cov}(X, Y)}{\sigma_X \sigma_Y} \in [-1, 1]. Measures the strength of linear association.

PART B — Long Essay (20 marks each) · 20 questions

Module 1 — Set Theory, Relations, Combinatorics

Statement. For three finite sets A,B,CA, B, C: ABC=A+B+CABACBC+ABC.|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|.

Proof. Take any element xABCx \in A \cup B \cup C, suppose it lies in exactly kk of the three sets.

  • LHS counts xx once.
  • RHS counts xx: (k1)\binom{k}{1} singletons − (k2)\binom{k}{2} pair-intersections + (k3)\binom{k}{3} triple.

For k=1,2,3k = 1, 2, 3: net = 10+0=11 - 0 + 0 = 1; 21+0=12 - 1 + 0 = 1; 33+1=13 - 3 + 1 = 1. So each element counted once on both sides. ∎

Application. Let AkA_k = multiples of kk in {1,,500}\{1, \dots, 500\}, so Ak=500/k|A_k| = \lfloor 500/k \rfloor.

  • A3=166,  A5=100,  A7=71|A_3| = 166, \; |A_5| = 100, \; |A_7| = 71.
  • A3A5=500/15=33|A_3 \cap A_5| = \lfloor 500/15 \rfloor = 33.
  • A3A7=500/21=23|A_3 \cap A_7| = \lfloor 500/21 \rfloor = 23.
  • A5A7=500/35=14|A_5 \cap A_7| = \lfloor 500/35 \rfloor = 14.
  • A3A5A7=500/105=4|A_3 \cap A_5 \cap A_7| = \lfloor 500/105 \rfloor = 4.

A3A5A7=166+100+71332314+4=271|A_3 \cup A_5 \cup A_7| = 166 + 100 + 71 - 33 - 23 - 14 + 4 = 271.

So 271 integers in 1–500 are divisible by 3, 5 or 7.

Definition. A relation \sim on AA that is reflexive, symmetric, and transitive. For aAa \in A, the equivalence class [a]={x:xa}[a] = \{x : x \sim a\}.

Theorem. The equivalence classes of \sim form a partition of AA.

Proof.

  1. Non-empty. Reflexivity: a[a]a \in [a], so [a][a] \ne \emptyset.
  2. Cover. Each a[a]a \in [a], so a[a]=A\bigcup_a [a] = A.
  3. Disjoint or equal. Suppose [a][b][a] \cap [b] \ne \emptyset, pick cc in both. Then cac \sim a and cbc \sim b. Symmetry gives aca \sim c, transitivity aba \sim b. For any x[a]x \in [a]: xabx \sim a \sim b, so x[b]x \in [b]. So [a][b][a] \subseteq [b]. By symmetry [a]=[b][a] = [b]. ∎

Verification with \sim on Z\mathbb{Z}, ab    4(ab)a \sim b \iff 4 \mid (a - b).

  • Reflexive: aa=0a - a = 0, divisible by 4. ✓
  • Symmetric: 4(ab)4(ba)4 \mid (a - b) \Rightarrow 4 \mid (b - a). ✓
  • Transitive: 4(ab)4 \mid (a-b) and 4(bc)4(ac)4 \mid (b-c) \Rightarrow 4 \mid (a-c). ✓

The four classes are [0],[1],[2],[3][0], [1], [2], [3] — residue classes mod 4 — and they partition Z\mathbb{Z}.

Principle. If P(n0)P(n_0) is true (base case) and P(k)P(k+1)P(k) \Rightarrow P(k+1) (induction step), then P(n)P(n) is true for all nn0n \ge n_0.

Part 1. Prove i=1ni=n(n+1)2\sum_{i=1}^{n} i = \dfrac{n(n+1)}{2}.

Base n=1n = 1: LHS = 1, RHS = 12/2=11 \cdot 2 / 2 = 1. ✓

Step. Assume i=1ki=k(k+1)/2\sum_{i=1}^{k} i = k(k+1)/2. Then i=1k+1i=k(k+1)2+(k+1)=k(k+1)+2(k+1)2=(k+1)(k+2)2\sum_{i=1}^{k+1} i = \dfrac{k(k+1)}{2} + (k+1) = \dfrac{k(k+1) + 2(k+1)}{2} = \dfrac{(k+1)(k+2)}{2}. ∎

Part 2. Prove 3(n3+2n)3 \mid (n^3 + 2n) for n1n \ge 1.

Base n=1n = 1: 1+2=31 + 2 = 3, divisible by 3. ✓

Step. Assume 3(k3+2k)3 \mid (k^3 + 2k), i.e., k3+2k=3mk^3 + 2k = 3m for some integer mm. Then (k+1)3+2(k+1)=k3+3k2+3k+1+2k+2=(k3+2k)+3k2+3k+3=3m+3(k2+k+1)(k+1)^3 + 2(k+1) = k^3 + 3k^2 + 3k + 1 + 2k + 2 = (k^3 + 2k) + 3k^2 + 3k + 3 = 3m + 3(k^2 + k + 1) — divisible by 3. ∎

(i) Choose 4 of 10 men and 3 of 8 women: (104)(83)=21056=11,760\binom{10}{4} \cdot \binom{8}{3} = 210 \cdot 56 = 11{,}760 ways.

(ii) "MATHEMATICS" has 11 letters: M×2, A×2, T×2, H, E, I, C, S. Arrangements =11!2!2!2!=39,916,8008=4,989,600= \dfrac{11!}{2! \, 2! \, 2!} = \dfrac{39{,}916{,}800}{8} = 4{,}989{,}600.

(iii) Treat the 2 specific persons as a single block: 5 units to arrange = 5!=1205! = 120. The 2 within the block can swap: 2!=22! = 2. Total =5!×2!=120×2=240= 5! \times 2! = 120 \times 2 = 240 ways.

Module 2 — Graph Theory

Theorem. A connected graph has an Eulerian circuit iff every vertex has even degree.

Proof. (⇒) If an Eulerian circuit exists, every time the walk enters a vertex it must leave by another edge. Edges at each vertex pair up, so every degree is even.

(⇐) Suppose connected and all even degree. Start a trail at any vertex v0v_0. The even-degree condition ensures that whenever we reach a vertex, an unused outgoing edge exists. The trail must return to v0v_0, forming a circuit C0C_0.

If C0C_0 uses all edges, done. Otherwise, by connectivity, some vertex on C0C_0 has unused edges; build another circuit and splice in. Repeat until all edges used. ∎

Verify K6K_6. K6K_6: every vertex has degree 55 (odd!). So K6K_6 does NOT have an Eulerian circuit. (Only KnK_n with nn odd does — degree n1n - 1 even.)

Hamiltonian. Visit vertices in cyclic order v1v2v6v1v_1 \to v_2 \to \dots \to v_6 \to v_1. Every consecutive pair is joined (complete graph). So K6K_6 DOES have a Hamiltonian circuit. Every KnK_n with n3n \ge 3 is Hamiltonian.

Algorithm.

Initialise d[v] = ∞ for all v; d[source] = 0
Use min-priority queue keyed by d[v]
while queue not empty:
    u = extract-min
    for each neighbour v of u:
        if d[u] + w(u,v) < d[v]:
            d[v] = d[u] + w(u,v)
            prev[v] = u

Greedy choice: always finalise unvisited vertex with smallest tentative distance. Complexity O((V+E)logV)O((V+E) \log V) with a heap.

Apply.

StepVisitedd[A]d[B]d[C]d[D]d[E]
init0
pick A{A}062
pick C{A,C}05*26**10
pick B{A,B,C}052610
pick D{A,B,C,D}05269***
pick Eall05269

*via ACBA \to C \to B (cost 2+3=52 + 3 = 5). **via ACDA \to C \to D (cost 2+4=62 + 4 = 6). ***via ACDEA \to C \to D \to E (cost 6+3=96 + 3 = 9).

Shortest path: ACDEA \to C \to D \to E, total cost 9.

Definitions.

  • Spanning tree: subgraph that is a tree and includes all vertices; has V1|V| - 1 edges.
  • MST: spanning tree with minimum total edge weight.

Kruskal's algorithm.

sort edges by weight ascending
Union-Find: each vertex its own component initially
for each edge (u, v) in order:
    if find(u) != find(v):
        add (u, v) to MST
        union(u, v)
    stop when |V| - 1 edges added

Apply. Sort edges: (B,D,1),(A,C,2),(B,C,3),(D,E,3),(C,D,4),(A,B,6),(C,E,8)(B,D,1), (A,C,2), (B,C,3), (D,E,3), (C,D,4), (A,B,6), (C,E,8).

#EdgeWeightAction
1(B, D)1add — {B,D}
2(A, C)2add — {A,C}, {B,D}
3(B, C)3add — merges to {A,B,C,D}
4(D, E)3add — {A,B,C,D,E}
stop4 edges = $V- 1$

MST edges: (B,D),(A,C),(B,C),(D,E)(B,D), (A,C), (B,C), (D,E). Total weight = 1+2+3+3=91 + 2 + 3 + 3 = 9.

Definitions.

  • Adjacency matrix ARn×nA \in \mathbb{R}^{n \times n}: Aij=1A_{ij} = 1 if (vi,vj)E(v_i, v_j) \in E, else 0. Symmetric for undirected graphs.
  • Incidence matrix BRn×mB \in \mathbb{R}^{n \times m}: Bij=1B_{ij} = 1 if vertex viv_i is on edge eje_j.

Key fact. (Ak)ij(A^k)_{ij} = number of walks of length exactly kk from viv_i to vjv_j.

Apply. A=(0110101111010110)A = \begin{pmatrix} 0 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 0 & 1 & 1 & 0 \end{pmatrix}

Compute A2A^2. Row 1:

  • (A2)11=0+1+1+0=2(A^2)_{11} = 0 + 1 + 1 + 0 = 2.
  • (A2)12=0+0+1+0=1(A^2)_{12} = 0 + 0 + 1 + 0 = 1.
  • (A2)13=0+1+0+0=1(A^2)_{13} = 0 + 1 + 0 + 0 = 1.
  • (A2)14=0+1+1+0=2(A^2)_{14} = 0 + 1 + 1 + 0 = 2.

By symmetry of AA, A2A^2 is symmetric. Continuing: A2=(2112132112312112)A^2 = \begin{pmatrix} 2 & 1 & 1 & 2 \\ 1 & 3 & 2 & 1 \\ 1 & 2 & 3 & 1 \\ 2 & 1 & 1 & 2 \end{pmatrix}

Interpretation. From vertex 1: 2 walks back to 1 (via 2 or 3), 1 walk to 2 (via 3), 1 walk to 3 (via 2), 2 walks to 4 (via 2 or 3). Diagonal entries equal vertex degrees.

Module 3 — Linear Algebra

Step 1 — Characteristic polynomial. det(AλI)=(6λ)(3λ)(1)(2)=λ29λ+20=(λ4)(λ5)\det(A - \lambda I) = (6-\lambda)(3-\lambda) - (-1)(2) = \lambda^2 - 9\lambda + 20 = (\lambda - 4)(\lambda - 5).

Eigenvalues: λ1=5,  λ2=4\lambda_1 = 5, \; \lambda_2 = 4. Check: sum =9=tr(A)= 9 = \text{tr}(A), product =20=det(A)= 20 = \det(A). ✓

Step 2 — Eigenvectors.

For λ=5\lambda = 5: (A5I)v=(1122)v=0x=y(A - 5I)v = \begin{pmatrix} 1 & -1 \\ 2 & -2 \end{pmatrix}v = 0 \Rightarrow x = y. Take v1=(1,1)Tv_1 = (1, 1)^T.

For λ=4\lambda = 4: (A4I)v=(2121)v=0y=2x(A - 4I)v = \begin{pmatrix} 2 & -1 \\ 2 & -1 \end{pmatrix}v = 0 \Rightarrow y = 2x. Take v2=(1,2)Tv_2 = (1, 2)^T.

Step 3 — Diagonalise. P=(1112),  D=(5004),  A=PDP1P = \begin{pmatrix} 1 & 1 \\ 1 & 2 \end{pmatrix}, \; D = \begin{pmatrix} 5 & 0 \\ 0 & 4 \end{pmatrix}, \; A = P D P^{-1}.

detP=1\det P = 1, so P1=(2111)P^{-1} = \begin{pmatrix} 2 & -1 \\ -1 & 1 \end{pmatrix}.

Step 4 — Compute A5A^5. A5=PD5P1A^5 = P D^5 P^{-1} where D5=(550045)=(3125001024)D^5 = \begin{pmatrix} 5^5 & 0 \\ 0 & 4^5 \end{pmatrix} = \begin{pmatrix} 3125 & 0 \\ 0 & 1024 \end{pmatrix}.

PD5=(3125102431252048)P D^5 = \begin{pmatrix} 3125 & 1024 \\ 3125 & 2048 \end{pmatrix}

A5=(3125102431252048)(2111)=(5226210142021077)A^5 = \begin{pmatrix} 3125 & 1024 \\ 3125 & 2048 \end{pmatrix} \begin{pmatrix} 2 & -1 \\ -1 & 1 \end{pmatrix} = \begin{pmatrix} 5226 & -2101 \\ 4202 & -1077 \end{pmatrix}.

Process. For ARm×nA \in \mathbb{R}^{m \times n}:

  1. Form ATAA^T A.
  2. Find eigenvalues λi\lambda_i and orthonormal eigenvectors viv_i of ATAA^T A → right singular vectors VV.
  3. Singular values σi=λi\sigma_i = \sqrt{\lambda_i}, sorted descending → Σ\Sigma.
  4. Left singular vectors ui=1σiAviu_i = \dfrac{1}{\sigma_i} A v_iUU.
  5. Then A=UΣVTA = U \Sigma V^T.

Apply.

Step 1. ATA=(3405)(3045)=(25202025)A^T A = \begin{pmatrix} 3 & 4 \\ 0 & 5 \end{pmatrix} \begin{pmatrix} 3 & 0 \\ 4 & 5 \end{pmatrix} = \begin{pmatrix} 25 & 20 \\ 20 & 25 \end{pmatrix}.

Step 2. det(ATAλI)=(25λ)2400=0λ=45 or 5\det(A^T A - \lambda I) = (25 - \lambda)^2 - 400 = 0 \Rightarrow \lambda = 45 \text{ or } 5.

Eigenvectors:

  • λ=45\lambda = 45: v1=12(1,1)Tv_1 = \frac{1}{\sqrt 2}(1, 1)^T.
  • λ=5\lambda = 5: v2=12(1,1)Tv_2 = \frac{1}{\sqrt 2}(1, -1)^T.

Step 3. σ1=45=35,  σ2=5\sigma_1 = \sqrt{45} = 3\sqrt 5, \; \sigma_2 = \sqrt 5.

Step 4. Left singular vectors: u1=135Av1=13512(39)=110(1,3)Tu_1 = \dfrac{1}{3\sqrt 5} A v_1 = \dfrac{1}{3\sqrt 5} \cdot \dfrac{1}{\sqrt 2}\begin{pmatrix} 3 \\ 9 \end{pmatrix} = \dfrac{1}{\sqrt{10}}(1, 3)^T.

u2=15Av2=1512(31)=110(3,1)Tu_2 = \dfrac{1}{\sqrt 5} A v_2 = \dfrac{1}{\sqrt 5} \cdot \dfrac{1}{\sqrt 2}\begin{pmatrix} 3 \\ -1 \end{pmatrix} = \dfrac{1}{\sqrt{10}}(3, -1)^T.

Result. U=110(1331),  Σ=(35005),  V=12(1111)U = \dfrac{1}{\sqrt{10}}\begin{pmatrix} 1 & 3 \\ 3 & -1 \end{pmatrix}, \; \Sigma = \begin{pmatrix} 3\sqrt 5 & 0 \\ 0 & \sqrt 5 \end{pmatrix}, \; V = \dfrac{1}{\sqrt 2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}.

Theorem. For an m×nm \times n matrix AA: rank(A)+nullity(A)=n\text{rank}(A) + \text{nullity}(A) = n.

Proof. Let kk = nullity, {v1,,vk}\{v_1, \dots, v_k\} a basis of N(A)N(A). Extend to basis {v1,,vn}\{v_1, \dots, v_n\} of Rn\mathbb{R}^n.

Claim: {Avk+1,,Avn}\{A v_{k+1}, \dots, A v_n\} is a basis of the column space.

  • Spans: any AvA v has v=civiv = \sum c_i v_i, so Av=i>kciAviA v = \sum_{i>k} c_i A v_i (first kk killed).
  • Independent: if i>kciAvi=0\sum_{i>k} c_i A v_i = 0 then A(i>kcivi)=0A(\sum_{i>k} c_i v_i) = 0, so this lies in N(A)N(A). But it's in the complement basis, so all ci=0c_i = 0.

Hence rank = nkn - k, giving rank + nullity = nn. ∎

Apply. Row-reduce: (123246369)R22R1,R33R1(123000000)\begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9 \end{pmatrix} \xrightarrow{R_2 - 2R_1,\, R_3 - 3R_1} \begin{pmatrix} 1 & 2 & 3 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{pmatrix}

One non-zero row ⇒ rank = 1. By rank-nullity: nullity = 3 - 1 = 2.

Null space spanned by (2,1,0)T(2, -1, 0)^T and (3,0,1)T(3, 0, -1)^T (or similar two-vector basis).

Inner product. For x,yRnx, y \in \mathbb{R}^n: x,y=xiyi\langle x, y \rangle = \sum x_i y_i. Satisfies bilinearity, symmetry, positivity. Induces norm x=x,x\|x\| = \sqrt{\langle x, x \rangle} and angle cosθ=x,yxy\cos\theta = \dfrac{\langle x, y \rangle}{\|x\| \|y\|}.

Cosine similarity = cosθ\cos\theta — scale-invariant. Used for text similarity, embeddings, recommender systems.

Distance metrics. Take x=(1,2)x = (1, 2), y=(4,6)y = (4, 6).

MetricFormulaValueUse
Euclidean (L2L_2)(xiyi)2\sqrt{\sum (x_i - y_i)^2}9+16=5\sqrt{9 + 16} = 5k-means, k-NN, generic
Manhattan (L1L_1)$\sumx_i - y_i$
Cosine1xyxy1 - \dfrac{x \cdot y}{\|x\|\|y\|}1162600.0081 - \frac{16}{\sqrt{260}} \approx 0.008Text, embeddings, direction matters
Mahalanobis(xy)TΣ1(xy)\sqrt{(x-y)^T \Sigma^{-1}(x-y)}depends on Σ\SigmaCorrelated features, anomaly detection

Summary. Euclidean is the default; Manhattan when outliers; Cosine for direction; Mahalanobis when features are correlated/have different scales.

Module 4 — Vectors and Geometry of Space

Dot product. ab=abcosθ\vec{a} \cdot \vec{b} = \|\vec{a}\| \|\vec{b}\| \cos\theta. With basis i^,j^,k^\hat i, \hat j, \hat k where i^i^=1,i^j^=0\hat i \cdot \hat i = 1, \hat i \cdot \hat j = 0, expansion gives ab=a1b1+a2b2+a3b3\vec{a} \cdot \vec{b} = a_1 b_1 + a_2 b_2 + a_3 b_3.

Cross product. a×b\vec{a} \times \vec{b} is perpendicular to both, magnitude absinθ\|\vec a\| \|\vec b\| \sin\theta, direction by right-hand rule. Using i^×j^=k^\hat i \times \hat j = \hat k etc: a×b=i^j^k^a1a2a3b1b2b3\vec{a} \times \vec{b} = \begin{vmatrix} \hat i & \hat j & \hat k \\ a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \end{vmatrix}.

Computations.

Dot: (2)(1)+(1)(3)+(1)(2)=232=3(2)(1) + (-1)(3) + (1)(-2) = 2 - 3 - 2 = -3.

Cross: a×b=i^j^k^211132\vec{a} \times \vec{b} = \begin{vmatrix} \hat i & \hat j & \hat k \\ 2 & -1 & 1 \\ 1 & 3 & -2 \end{vmatrix} =i^((1)(2)(1)(3))j^((2)(2)(1)(1))+k^((2)(3)(1)(1))= \hat i((-1)(-2) - (1)(3)) - \hat j((2)(-2) - (1)(1)) + \hat k((2)(3) - (-1)(1)) =i^(23)j^(41)+k^(6+1)=(1,5,7)= \hat i(2 - 3) - \hat j(-4 - 1) + \hat k(6 + 1) = (-1, 5, 7).

Magnitudes: a=4+1+1=6\|\vec a\| = \sqrt{4 + 1 + 1} = \sqrt 6, b=1+9+4=14\|\vec b\| = \sqrt{1 + 9 + 4} = \sqrt{14}.

Angle: cosθ=3614=3840.327\cos\theta = \dfrac{-3}{\sqrt 6 \sqrt{14}} = \dfrac{-3}{\sqrt{84}} \approx -0.327. θ109.1°\theta \approx 109.1°.

Parallelogram area: a×b=1+25+49=75=538.66\|\vec a \times \vec b\| = \sqrt{1 + 25 + 49} = \sqrt{75} = 5\sqrt 3 \approx 8.66.

Derivation. For plane Π:ax+by+cz+d=0\Pi: ax + by + cz + d = 0 with normal n=(a,b,c)\vec{n} = (a, b, c), and point P0(x0,y0,z0)P_0(x_0, y_0, z_0). Let QQ = foot of perpendicular from P0P_0 to Π\Pi. Then P0Q=λn\vec{P_0 Q} = \lambda \vec{n}, so Q=P0+λnQ = P_0 + \lambda \vec{n}. Substituting into the plane:

a(x0+λa)+b(y0+λb)+c(z0+λc)+d=0a(x_0 + \lambda a) + b(y_0 + \lambda b) + c(z_0 + \lambda c) + d = 0 λ=ax0+by0+cz0+da2+b2+c2\Rightarrow \lambda = -\dfrac{a x_0 + b y_0 + c z_0 + d}{a^2 + b^2 + c^2}.

Distance = λn=ax0+by0+cz0+da2+b2+c2|\lambda| \|\vec{n}\| = \dfrac{|a x_0 + b y_0 + c z_0 + d|}{\sqrt{a^2 + b^2 + c^2}}. ∎

Plane through P,Q,RP, Q, R.

Edge vectors: PQ=(2,1,1)\vec{PQ} = (2, -1, -1), PR=(1,1,2)\vec{PR} = (-1, 1, 2).

Normal n=PQ×PR\vec{n} = \vec{PQ} \times \vec{PR}: n=i^j^k^211112\vec{n} = \begin{vmatrix} \hat i & \hat j & \hat k \\ 2 & -1 & -1 \\ -1 & 1 & 2 \end{vmatrix} =i^((1)(2)(1)(1))j^((2)(2)(1)(1))+k^((2)(1)(1)(1))= \hat i((-1)(2) - (-1)(1)) - \hat j((2)(2) - (-1)(-1)) + \hat k((2)(1) - (-1)(-1)) =i^(1)j^(3)+k^(1)=(1,3,1)= \hat i(-1) - \hat j(3) + \hat k(1) = (-1, -3, 1).

Plane equation using P(1,1,2)P(1, 1, 2): (x1)3(y1)+(z2)=0-(x - 1) - 3(y - 1) + (z - 2) = 0 x+13y+3+z2=0-x + 1 - 3y + 3 + z - 2 = 0 x+3yz=2\boxed{x + 3y - z = 2} (after multiplying by 1-1).

Distance from origin. d=0+0021+9+1=2110.603d = \dfrac{|0 + 0 - 0 - 2|}{\sqrt{1 + 9 + 1}} = \dfrac{2}{\sqrt{11}} \approx 0.603.

Derivation. For skew lines L1:r1+td1L_1: \vec{r}_1 + t \vec{d}_1 and L2:r2+sd2L_2: \vec{r}_2 + s \vec{d}_2.

The common perpendicular direction is n=d1×d2\vec{n} = \vec{d}_1 \times \vec{d}_2. The shortest distance equals the absolute projection of (r2r1)(\vec{r}_2 - \vec{r}_1) onto n\vec{n}:

d=(r2r1)(d1×d2)d1×d2.d = \dfrac{|(\vec{r}_2 - \vec{r}_1) \cdot (\vec{d}_1 \times \vec{d}_2)|}{\|\vec{d}_1 \times \vec{d}_2\|}.

Apply. d1=(1,1,2)\vec{d}_1 = (1, -1, 2), d2=(2,1,1)\vec{d}_2 = (2, 1, -1), r2r1=(1,2,2)\vec{r}_2 - \vec{r}_1 = (1, -2, -2).

d1×d2=i^j^k^112211\vec{d}_1 \times \vec{d}_2 = \begin{vmatrix} \hat i & \hat j & \hat k \\ 1 & -1 & 2 \\ 2 & 1 & -1 \end{vmatrix} =i^((1)(1)(2)(1))j^((1)(1)(2)(2))+k^((1)(1)(1)(2))= \hat i((-1)(-1) - (2)(1)) - \hat j((1)(-1) - (2)(2)) + \hat k((1)(1) - (-1)(2)) =i^(1)j^(5)+k^(3)=(1,5,3)= \hat i(-1) - \hat j(-5) + \hat k(3) = (-1, 5, 3).

d1×d2=1+25+9=35\|\vec{d}_1 \times \vec{d}_2\| = \sqrt{1 + 25 + 9} = \sqrt{35}.

(r2r1)(d1×d2)=(1)(1)+(2)(5)+(2)(3)=1106=17(\vec{r}_2 - \vec{r}_1) \cdot (\vec{d}_1 \times \vec{d}_2) = (1)(-1) + (-2)(5) + (-2)(3) = -1 - 10 - 6 = -17.

d=17352.873d = \dfrac{17}{\sqrt{35}} \approx 2.873.

Scalar triple product. [a,b,c]=a(b×c)[\vec{a}, \vec{b}, \vec{c}] = \vec{a} \cdot (\vec{b} \times \vec{c}).

Geometric meaning. Base = parallelogram with edges b,c\vec{b}, \vec{c}, area b×c\|\vec{b} \times \vec{c}\|, and b×c\vec{b} \times \vec{c} perpendicular to it. The height equals the projection of a\vec{a} onto b×c\vec{b} \times \vec{c}. Hence

Volume = base × height = b×ca(b×c)b×c=a(b×c)\|\vec{b} \times \vec{c}\| \cdot \dfrac{|\vec{a} \cdot (\vec{b} \times \vec{c})|}{\|\vec{b} \times \vec{c}\|} = |\vec{a} \cdot (\vec{b} \times \vec{c})|.

Equivalently as a determinant: [a,b,c]=det(a1a2a3b1b2b3c1c2c3)[\vec{a}, \vec{b}, \vec{c}] = \det\begin{pmatrix} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ c_1 & c_2 & c_3 \end{pmatrix}.

If this determinant is zero, the three vectors are coplanar.

Apply. det(102210031)=1(10)0+2(60)=1+12=13\det\begin{pmatrix} 1 & 0 & 2 \\ 2 & 1 & 0 \\ 0 & 3 & 1 \end{pmatrix} = 1 \cdot (1 - 0) - 0 + 2 \cdot (6 - 0) = 1 + 12 = 13.

Volume = 13=13|13| = 13 cubic units.

Since the determinant is non-zero, the three vectors are not coplanar — they truly span a 3D parallelepiped.

Module 5 — Probability Theory

Bayes' theorem. If {B1,,Bn}\{B_1, \dots, B_n\} partitions Ω\Omega with P(Bi)>0P(B_i) > 0 and AA has P(A)>0P(A) > 0: P(BkA)=P(ABk)P(Bk)iP(ABi)P(Bi).P(B_k \mid A) = \dfrac{P(A \mid B_k) P(B_k)}{\sum_i P(A \mid B_i) P(B_i)}.

Proof. From definition: P(BkA)=P(ABk)P(Bk)=P(BkA)P(A)P(B_k \cap A) = P(A \mid B_k) P(B_k) = P(B_k \mid A) P(A). So P(BkA)=P(ABk)P(Bk)P(A)P(B_k \mid A) = \dfrac{P(A \mid B_k) P(B_k)}{P(A)}. By law of total probability: P(A)=iP(ABi)P(Bi)P(A) = \sum_i P(A \mid B_i) P(B_i). Substituting gives Bayes' formula. ∎

Disease problem.

Let DD = "has disease", TT = "tests positive". Given:

  • P(D)=0.01,  P(Dc)=0.99P(D) = 0.01, \; P(D^c) = 0.99.
  • Sensitivity: P(TD)=0.95P(T \mid D) = 0.95.
  • Specificity: P(TcDc)=0.90P(T^c \mid D^c) = 0.90, so false-positive P(TDc)=0.10P(T \mid D^c) = 0.10.

Total probability: P(T)=(0.95)(0.01)+(0.10)(0.99)=0.0095+0.099=0.1085P(T) = (0.95)(0.01) + (0.10)(0.99) = 0.0095 + 0.099 = 0.1085.

Bayes: P(DT)=(0.95)(0.01)0.1085=0.00950.10850.0876P(D \mid T) = \dfrac{(0.95)(0.01)}{0.1085} = \dfrac{0.0095}{0.1085} \approx 0.0876.

So only about 8.76% chance the patient actually has the disease! Even a highly accurate test fails when the disease is rare — false positives dominate. This is the base-rate fallacy.

Types of random variables.

A random variable X:ΩRX: \Omega \to \mathbb{R} assigns a real number to each outcome. Two main types:

Discrete RV. Takes countably many values. Described by PMF p(x)=P(X=x)p(x) = P(X = x) with xp(x)=1\sum_x p(x) = 1.

Continuous RV. Takes values in an interval. Described by PDF f(x)0f(x) \ge 0 with f=1\int f = 1.

Distributions.

DistributionPMF / PDFMeanVarianceUse
Bernoulli(p)(p)P(X=1)=p,P(X=0)=1pP(X = 1) = p, P(X = 0) = 1 - pppp(1p)p(1-p)Single yes/no trial
Binomial(n,p)(n, p)(nk)pk(1p)nk\binom{n}{k} p^k (1-p)^{n-k}npnpnp(1p)np(1-p)# successes in nn trials
Poisson(λ)(\lambda)eλλk/k!e^{-\lambda} \lambda^k / k!λ\lambdaλ\lambdaRare event counts
Uniform(a,b)(a, b)1ba\dfrac{1}{b-a} on [a,b][a,b]a+b2\dfrac{a+b}{2}(ba)212\dfrac{(b-a)^2}{12}Equal-likelihood
Exponential(λ)(\lambda)λeλx,x0\lambda e^{-\lambda x}, x \ge 01/λ1/\lambda1/λ21/\lambda^2Waiting times
Normal(μ,σ2)(\mu, \sigma^2)1σ2πe(xμ)2/(2σ2)\dfrac{1}{\sigma\sqrt{2\pi}} e^{-(x-\mu)^2 / (2\sigma^2)}μ\muσ2\sigma^2Natural variation, errors

Importance. Bernoulli is the basic unit; Binomial = sum of nn Bernoullis. Poisson approximates Binomial when nn large, pp small with np=λnp = \lambda. The Normal arises naturally by the Central Limit Theorem — sums of many independent random variables tend to Normal regardless of original distribution.

Algorithm. Given target density f(x)f(x), easy-to-sample proposal g(x)g(x), and constant MM with Mg(x)f(x)M g(x) \ge f(x) for all xx:

loop:
    X ~ g
    U ~ Uniform(0, 1)
    if U <= f(X) / (M * g(X)):  accept X, return
    else:                       reject, repeat

Proof. Let AA = "accept this iteration".

P(A,Xx)=xg(y)f(y)Mg(y)dy=F(x)MP(A, X \le x) = \int_{-\infty}^x g(y) \cdot \dfrac{f(y)}{M g(y)} dy = \dfrac{F(x)}{M}.

So P(A)=1/MP(A) = 1/M and P(XxA)=F(x)P(X \le x \mid A) = F(x) — accepted XX has the target CDF. ∎

Application. Target f(x)ex2/2f(x) \propto e^{-x^2/2} on [0,1][0, 1]. Normalisation: 01ex2/2dx0.8556\int_0^1 e^{-x^2/2} dx \approx 0.8556, so f(x)=ex2/2/0.8556f(x) = e^{-x^2/2}/0.8556 for x[0,1]x \in [0, 1].

Proposal: g(x)=1g(x) = 1 (uniform on [0,1][0, 1]).

ff is maximised at x=0x = 0: f(0)=1/0.85561.169f(0) = 1/0.8556 \approx 1.169. So M=1.17M = 1.17 works.

Algorithm:

  1. XUniform(0,1)X \sim \text{Uniform}(0, 1).
  2. UUniform(0,1)U \sim \text{Uniform}(0, 1).
  3. Accept if Uf(X)/1.17U \le f(X) / 1.17.

Acceptance rate 1/1.1785%\approx 1/1.17 \approx 85\% — very efficient.

Variance identity. Var(X)=E[(Xμ)2]=E[X22μX+μ2]=E[X2]2μE[X]+μ2=E[X2]μ2\text{Var}(X) = E[(X - \mu)^2] = E[X^2 - 2\mu X + \mu^2] = E[X^2] - 2\mu E[X] + \mu^2 = E[X^2] - \mu^2. ∎

Linearity of expectation. For any random variables X,YX, Y and scalars a,ba, b: E[aX+bY]=aE[X]+bE[Y]E[a X + b Y] = a E[X] + b E[Y].

This holds without any independence assumption. For variance, Var(X+Y)=Var(X)+Var(Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) requires XYX \perp Y.

Binomial mean and variance via linearity.

Write X=X1+X2++XnX = X_1 + X_2 + \dots + X_n, where each XiBernoulli(p)X_i \sim \text{Bernoulli}(p) independent.

Mean. E[Xi]=pE[X_i] = p. By linearity: E[X]=E[Xi]=npE[X] = \sum E[X_i] = n p.

Variance. Var(Xi)=p(1p)\text{Var}(X_i) = p(1-p). By independence: Var(X)=Var(Xi)=np(1p)\text{Var}(X) = \sum \text{Var}(X_i) = n p (1 - p).

For n=20,p=0.4n = 20, p = 0.4.

  • Mean = 20×0.4=820 \times 0.4 = 8.
  • Variance = 20×0.4×0.6=4.820 \times 0.4 \times 0.6 = 4.8.
  • Standard deviation = 4.82.19\sqrt{4.8} \approx 2.19.

So a Binomial(20,0.4)(20, 0.4) has expected value 8 and typical fluctuations of about ±2.2\pm 2.2 around 8.

End of question bank. Total: 100 Part-A (200 marks possible) + 20 Part-B (400 marks possible) = 600 marks of practice material. All five modules covered with 20 + 4 questions each.