Math for AI & Data Science · ClipSAT

⏱ Exam Timer: 00:00

Math for AI & Data Science

Focus · Linear Algebra, Calculus & Probabilistic ML Target Level · Grades 11–12 / University STEM Bridge Core Chapters · 8 Foundational Units Interactive Explorers · 4 Visual ML Explorers
✓ Official Syllabus Verified Last reviewed against official syllabus: 2025–2026 Academic Year Standards & Rigor ↗
1

Vectors, Norms & High-Dimensional Embeddings

🤖 AI Math Unit 1 — Vectors & Geometric Embeddings Applied STEM  ·  Vector spaces & column vectors  ·  L1 (Manhattan) and L2 (Euclidean) norms  ·  Dot products & vector projections  ·  Cosine similarity in NLP & vector search  ·  Word and token embeddings (Word2Vec / Transformer)

In Artificial Intelligence and Natural Language Processing, text, images, and audio are mapped to high-dimensional numerical vectors called embeddings. We explore vector geometry, norms, and distance metrics used in modern vector databases.

📊 Math for AI & Data Science — Exam Blueprint & Domain Weighting

Vectors & Embeddings
~25% MATHAI
Matrices & Neural Layers
~25% MATHAI
Gradient Descent & Loss
~25% MATHAI
Probability, Bayes & PCA
~25% MATHAI

Official curriculum weighting and examination domain distribution for Math for AI & Data Science.

● Definition 1.1 — Vector Norms & Distances
For a vector x=[x1,x2,…,xn]T∈Rn \mathbf{x} = [x_1, x_2, \dots, x_n]^T \in \mathbb{R}^n :
1. Euclidean (L2 L_2 ) Norm: ∥x∥2=∑i=1nxi2=xTx \|\mathbf{x}\|_2 = \sqrt{\sum_{i=1}^n x_i^2} = \sqrt{\mathbf{x}^T\mathbf{x}} . Measures straight-line geometric distance.
2. Manhattan (L1 L_1 ) Norm: ∥x∥1=∑i=1n∣xi∣ \|\mathbf{x}\|_1 = \sum_{i=1}^n |x_i| . Used in Lasso regularization (L1 sparsity).
3. Max (L∞ L_\infty ) Norm: ∥x∥∞=max⁡i∣xi∣ \|\mathbf{x}\|_\infty = \max_i |x_i| . Used in adversarial robustness attacks (FGSM).
● Deep Conceptual Intuition — Vectors, Norms & High-Dimensional Embeddings

Linear Structure, Inner Products & Geometric Transformations: In Rn\mathbb{R}^n, the dot product u⋅v=∥u∥∥v∥cos⁡θ=∑i=1nuivi\mathbf{u}\cdot\mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos\theta = \sum_{i=1}^n u_i v_i encodes orthogonality (u⊥v  ⟺  u⋅v=0\mathbf{u}\perp\mathbf{v} \iff \mathbf{u}\cdot\mathbf{v} = 0) and orthogonal projection proj⁡vu=u⋅v∥v∥2v\operatorname{proj}_{\mathbf{v}}\mathbf{u} = \dfrac{\mathbf{u}\cdot\mathbf{v}}{\|\mathbf{v}\|^2}\mathbf{v}. For a matrix transformation A∈Rn×nA \in \mathbb{R}^{n\times n}, ∣det⁡(A)∣|\det(A)| measures the local volume scaling factor, and AA is invertible if and only if det⁡(A)≠0\det(A) \ne 0 (equivalently, all eigenvalues λi≠0\lambda_i \ne 0).

Coordinate transformation grid showing object and transformed image: Vectors, Norms & High-Dimensional Embeddings — Linear Transformation & Basis Action-6-2246-6-4-2246ABCA′B′C′Linear Transformation & Basis Action
Coordinate grid showing geometric action of a linear transformation mapping △ABC to its image △A'B'C'.
⊙ Explorer · Embedding Space: Cosine Similarity cos⁡θ\cos \theta & L1L_{1} vs. L2L_{2} Norm Balls
interactive
Cosine Similarity cos⁡(Δθ)\cos(\Delta \theta)cos⁡Δθ=0.707\cos \Delta \theta = 0.707
Euclidean Distance ∥u−v∥\|u - v\|₂∥u−v∥2=0.765\|u-v\|_{2} = 0.765
Manhattan Distance ∥u−v∥\|u - v\|₁∥u−v∥1=1.073\|u-v\|_{1} = 1.073

Compare two embedding vectors uu and vv on the unit L2L_{2} circle (indigo) and unit L1L_{1} diamond (dashed gray), tracking their dot-product cosine similarity cos⁡(θu−θv)\cos(\theta_u - \theta_v).

Scatter plot112344131824293540(1, 16)(2, 23)(3, 30)(4, 37)
Vectors, Norms & High-Dimensional Embeddings — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Vectors, Norms & High-Dimensional Embeddings.
Dot Product
u⋅v=∑i=1nuivi=uTv \mathbf{u} \cdot \mathbf{v} = \sum_{i=1}^n u_i v_i = \mathbf{u}^T\mathbf{v}
Cosine Similarity
cos⁡θ=u⋅v∥u∥∥v∥∈[−1,1] \cos\theta = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\| \|\mathbf{v}\|} \in [-1, 1]
Cosine Distance
Dcos⁡(u,v)=1−cos⁡θ D_{\cos}(\mathbf{u}, \mathbf{v}) = 1 - \cos\theta
Orthogonality
u⊥v  ⟺  uTv=0  ⟹  cos⁡θ=0 \mathbf{u} \perp \mathbf{v} \iff \mathbf{u}^T\mathbf{v} = 0 \implies \cos\theta = 0
◆ Why It Works — First-Principles Derivation (Vectors, Norms & High-Dimensional Embeddings)

Why Orthogonal Projection & Eigenvalue Characteristic Equations Work: Decompose u=cv+w\mathbf{u} = c\mathbf{v} + \mathbf{w} where w⊥v\mathbf{w} \perp \mathbf{v}. Taking the dot product with v\mathbf{v} uses w⋅v=0\mathbf{w}\cdot\mathbf{v} = 0 to isolate cc:

u⋅v=c(v⋅v)+0  ⟹  c=u⋅v∥v∥2 \mathbf{u}\cdot\mathbf{v} = c(\mathbf{v}\cdot\mathbf{v}) + 0 \implies c = \frac{\mathbf{u}\cdot\mathbf{v}}{\|\mathbf{v}\|^2}

For eigenvalues, Av=λvA\mathbf{v} = \lambda\mathbf{v} with v≠0\mathbf{v} \ne \mathbf{0} is equivalent to (A−λI)v=0(A - \lambda I)\mathbf{v} = \mathbf{0}. A homogeneous linear system has a non-trivial nullspace vector v≠0\mathbf{v} \ne \mathbf{0} if and only if the matrix A−λIA - \lambda I is singular, yielding the characteristic polynomial det⁡(A−λI)=0\det(A - \lambda I) = 0.

Worked Example 1.A — Cosine Similarity Between Word Embeddings

In an NLP embedding model, the word vectors for 'king' and 'queen' in a 3-dimensional subspace are u=[0.8,0.6,0.0]T \mathbf{u} = [0.8, 0.6, 0.0]^T and v=[0.6,0.8,0.0]T \mathbf{v} = [0.6, 0.8, 0.0]^T . An unrelated word 'apple' has vector w=[0.0,0.1,0.99]T \mathbf{w} = [0.0, 0.1, 0.99]^T . Calculate the cosine similarity between 'king' and 'queen', and between 'king' and 'apple'.

Solution:
1. Norm of u \mathbf{u} : ∥u∥=0.82+0.62+02=0.64+0.36=1.0 \|\mathbf{u}\| = \sqrt{0.8^2 + 0.6^2 + 0^2} = \sqrt{0.64 + 0.36} = 1.0 .
2. Norm of v \mathbf{v} : ∥v∥=0.62+0.82+02=1.0 \|\mathbf{v}\| = \sqrt{0.6^2 + 0.8^2 + 0^2} = 1.0 .
3. Dot product: u⋅v=(0.8)(0.6)+(0.6)(0.8)+(0)(0)=0.48+0.48=0.96 \mathbf{u} \cdot \mathbf{v} = (0.8)(0.6) + (0.6)(0.8) + (0)(0) = 0.48 + 0.48 = 0.96 .
Cosine similarity: cos⁡θuv=0.96(1.0)(1.0)=0.96 \cos\theta_{uv} = \frac{0.96}{(1.0)(1.0)} = 0.96 (very high semantic similarity!).

4. Now check 'king' and 'apple':
u⋅w=(0.8)(0)+(0.6)(0.1)+(0)(0.99)=0.06 \mathbf{u} \cdot \mathbf{w} = (0.8)(0) + (0.6)(0.1) + (0)(0.99) = 0.06 .
Norm ∥w∥=02+0.01+0.9801=0.9901≈0.995 \|\mathbf{w}\| = \sqrt{0^2 + 0.01 + 0.9801} = \sqrt{0.9901} \approx 0.995 .
Cosine similarity: cos⁡θuw=0.06(1.0)(0.995)≈0.0603 \cos\theta_{uw} = \frac{0.06}{(1.0)(0.995)} \approx 0.0603 (near orthogonal, no semantic relation).
Answer: cos⁡θuv=0.96 \cos\theta_{uv} = 0.96 ; cos⁡θuw≈0.060 \cos\theta_{uw} \approx 0.060 .

Worked Example BB — Vectors, Norms & High-Dimensional Embeddings (Easy Application)

Problem (Easy): Consider a simple logistic regression model where the decision boundary is defined by the equation 3x+4y−12=0 3x + 4y - 12 = 0 . This equation represents a linear boundary in a 2D feature space. What is the y-intercept of this decision boundary?

Step-by-Step Solution: The equation of the decision boundary is given by 3x+4y−12=0 3x + 4y - 12 = 0 . To find the y-intercept, we set x=0 x = 0 and solve for y y . \nSubstituting x=0 x = 0 into the equation: \n3(0)+4y−12=0 3(0) + 4y - 12 = 0 4y−12=0 4y - 12 = 0 4y=12 4y = 12 y=124 y = \frac{12}{4} y=3 y = 3 Therefore, the y-intercept of the decision boundary is 3.

Worked Example CC — Vectors, Norms & High-Dimensional Embeddings (Medium Application)

Problem (Medium): A linear transformation is defined by the matrix M=(2134)M = \begin{pmatrix} 2 & 1 \\ 3 & 4 \end{pmatrix}. If an input vector is v=(x1)v = \begin{pmatrix} x \\ 1 \end{pmatrix}, and the output vector after the transformation is w=(57)w = \begin{pmatrix} 5 \\ 7 \end{pmatrix}, what is the value of xx?

Step-by-Step Solution: The linear transformation is given by w=Mvw = Mv. Substituting the given matrices and vectors, we have: (37)=(2134)(x1) \begin{pmatrix} 3 \\ 7 \end{pmatrix} = \begin{pmatrix} 2 & 1 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} x \\ 1 \end{pmatrix} Performing the matrix multiplication on the right side gives: (37)=(2x+1(1)3x+4(1))=(2x+13x+4) \begin{pmatrix} 3 \\ 7 \end{pmatrix} = \begin{pmatrix} 2x + 1(1) \\ 3x + 4(1) \end{pmatrix} = \begin{pmatrix} 2x + 1 \\ 3x + 4 \end{pmatrix} Equating the corresponding components of the vectors, we get two equations: 1. 3=2x+13 = 2x + 1 2. 7=3x+47 = 3x + 4 Solving the first equation for xx: 3−1=2x3 - 1 = 2x 2=2x2 = 2x x=22x = \frac{2}{2} x=1x = 1 Solving the second equation for xx: 7−4=3x7 - 4 = 3x 3=3x3 = 3x x=33x = \frac{3}{3} x=1x = 1 Both equations yield x=1x=1. Therefore, the value of xx is 1.

Worked Example DD — Vectors, Norms & High-Dimensional Embeddings (Hard Application)

Problem (Hard): Consider two vectors, u=[34] \mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2] \mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix} . What is the vector representing 2u−v 2\mathbf{u} - \mathbf{v} ?

Step-by-Step Solution: To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result. 2u=2×[34]=[2×32×4]=[68] 2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} . Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510] 2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix} . Therefore, the resulting vector is [510] \begin{bmatrix} 5 \\ 10 \end{bmatrix} .

⚠️ Common Exam Traps — Vectors, Norms & High-Dimensional Embeddings

1. Non-Commutativity of Matrix Multiplication & Cross Products: On Mathematics for Artificial Intelligence & Machine Learning, assuming AB=BAAB = BA (so expanding (A+B)2(A+B)^2 as A2+2AB+B2A^2 + 2AB + B^2 instead of A2+AB+BA+B2A^2 + AB + BA + B^2) or forgetting u×v=−(v×u)\mathbf{u}\times\mathbf{v} = -(\mathbf{v}\times\mathbf{u}) invalidates matrix proofs.

2. Using Position Vectors Instead of Direction Vectors for Angles: To find the angle at vertex BB of triangle ABCABC, you must use tail-to-tail vectors BA→\overrightarrow{BA} and BC→\overrightarrow{BC}, never AB→⋅BC→\overrightarrow{AB}\cdot\overrightarrow{BC} (which finds the exterior supplementary angle 180∘−B180^\circ - B).

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Vectors, Norms & High-Dimensional Embeddings)
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Computing angle at BB using AB→⋅BC→\overrightarrow{AB}\cdot\overrightarrow{BC} Vectors are head-to-tail instead of tail-to-tail, giving 180∘−θ180^\circ - \theta. Reverse AB→\overrightarrow{AB} so both emanate from BB: use BA→⋅BC→\overrightarrow{BA}\cdot\overrightarrow{BC}.
Using the same parameter tt for two intersecting 3D lines r1(t)=r2(t)\mathbf{r}_1(t) = \mathbf{r}_2(t) Tests for a simultaneous collision at time tt rather than geometric intersection of paths. Assign distinct parameters λ\lambda and μ\mu to the two lines before equating components.
Assuming (AB)−1=A−1B−1(AB)^{-1} = A^{-1}B^{-1} Multiplying (AB)(A−1B−1)(AB)(A^{-1}B^{-1}) does not cancel inner factors when AB≠BAAB \ne BA. Use the shoe-sock reversal law: (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1}.
▲ Exam Pacing & Verification Strategy — Vectors, Norms & High-Dimensional Embeddings

Fast Matrix & Vector Verification (Mathematics for Artificial Intelligence & Machine Learning): Check every 2×22\times 2 or 3×33\times 3 eigenvalue computation using the trace and determinant invariants: ∑λi=tr⁡(A)\sum \lambda_i = \operatorname{tr}(A) (sum of diagonal entries) and ∏λi=det⁡(A)\prod \lambda_i = \det(A).

[Practice 1 · Easy] Consider two vectors, u=[34] \mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2] \mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix} . What is the vector representing 2u−v 2\mathbf{u} - \mathbf{v} ?
💡 Hint 1 of 3
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result.
💡 Hint 2 of 3
Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix}.
💡 Hint 3 of 3
Therefore, the resulting vector is [510]\begin{bmatrix} 5 \\ 10 \end{bmatrix}.
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result. 2u=2×[34]=[2×32×4]=[68] 2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} . Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510] 2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix} . Therefore, the resulting vector is [510] \begin{bmatrix} 5 \\ 10 \end{bmatrix} .
[Practice 2 · Medium] Consider two vectors, u=[34] \mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2] \mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix} . What is the vector representing 2u−v 2\mathbf{u} - \mathbf{v} ?
💡 Hint 1 of 3
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result.
💡 Hint 2 of 3
Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix}.
💡 Hint 3 of 3
Therefore, the resulting vector is [510]\begin{bmatrix} 5 \\ 10 \end{bmatrix}.
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result. 2u=2×[34]=[2×32×4]=[68] 2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} . Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510] 2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix} . Therefore, the resulting vector is [510] \begin{bmatrix} 5 \\ 10 \end{bmatrix} .
[Practice 3 · Hard] Consider two vectors, u=[34] \mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2] \mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix} . What is the vector representing 2u−v 2\mathbf{u} - \mathbf{v} ?
💡 Hint 1 of 3
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result.
💡 Hint 2 of 3
Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix}.
💡 Hint 3 of 3
Therefore, the resulting vector is [510]\begin{bmatrix} 5 \\ 10 \end{bmatrix}.
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result. 2u=2×[34]=[2×32×4]=[68] 2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} . Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510] 2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix} . Therefore, the resulting vector is [510] \begin{bmatrix} 5 \\ 10 \end{bmatrix} .
[Practice 4 · Easy] Consider two vectors, u=[34] \mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2] \mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix} . What is the vector representing 2u−v 2\mathbf{u} - \mathbf{v} ?
💡 Hint 1 of 3
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result.
💡 Hint 2 of 3
Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix}.
💡 Hint 3 of 3
Therefore, the resulting vector is [510]\begin{bmatrix} 5 \\ 10 \end{bmatrix}.
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result. 2u=2×[34]=[2×32×4]=[68] 2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} . Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510] 2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix} . Therefore, the resulting vector is [510] \begin{bmatrix} 5 \\ 10 \end{bmatrix} .
[Practice 5 · Medium] Consider two vectors, u=[34] \mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2] \mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix} . What is the vector representing 2u−v 2\mathbf{u} - \mathbf{v} ?
💡 Hint 1 of 3
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result.
💡 Hint 2 of 3
Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix}.
💡 Hint 3 of 3
Therefore, the resulting vector is [510]\begin{bmatrix} 5 \\ 10 \end{bmatrix}.
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result. 2u=2×[34]=[2×32×4]=[68] 2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} . Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510] 2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix} . Therefore, the resulting vector is [510] \begin{bmatrix} 5 \\ 10 \end{bmatrix} .
📝 Chapter Quiz
2

Matrices, Linear Layers & Activation Functions

🤖 AI Math Unit 2 — Neural Matrix Operations Applied STEM  ·  Matrix multiplication as linear transformation  ·  Dense layer forward pass y = Wx + b  ·  Dimensions, shapes & batching  ·  Non-linear activations: ReLU, Sigmoid, Softmax  ·  Universal approximation theorem intuition

Deep neural networks are sequences of matrix multiplications alternated with non-linear activation functions. Here we formulate the algebraic forward pass of dense feedforward neural layers.

● Definition 2.1 — Dense Neural Layer Formulation
A fully connected (dense) neural network layer with nin n_{\text{in}} inputs and nout n_{\text{out}} neurons computes an affine linear transformation followed by an element-wise activation σ \sigma :
z=Wx+b,a=σ(z) \mathbf{z} = \mathbf{W}\mathbf{x} + \mathbf{b}, \quad \mathbf{a} = \sigma(\mathbf{z})
where W∈Rnout×nin \mathbf{W} \in \mathbb{R}^{n_{\text{out}} \times n_{\text{in}}} is the weight matrix, x∈Rnin \mathbf{x} \in \mathbb{R}^{n_{\text{in}}} is the input vector, b∈Rnout \mathbf{b} \in \mathbb{R}^{n_{\text{out}}} is the bias vector, and a∈Rnout \mathbf{a} \in \mathbb{R}^{n_{\text{out}}} is the layer activation vector.
● Deep Conceptual Intuition — Matrices, Linear Layers & Activation Functions

Linear Structure, Inner Products & Geometric Transformations: In Rn\mathbb{R}^n, the dot product u⋅v=∥u∥∥v∥cos⁡θ=∑i=1nuivi\mathbf{u}\cdot\mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos\theta = \sum_{i=1}^n u_i v_i encodes orthogonality (u⊥v  ⟺  u⋅v=0\mathbf{u}\perp\mathbf{v} \iff \mathbf{u}\cdot\mathbf{v} = 0) and orthogonal projection proj⁡vu=u⋅v∥v∥2v\operatorname{proj}_{\mathbf{v}}\mathbf{u} = \dfrac{\mathbf{u}\cdot\mathbf{v}}{\|\mathbf{v}\|^2}\mathbf{v}. For a matrix transformation A∈Rn×nA \in \mathbb{R}^{n\times n}, ∣det⁡(A)∣|\det(A)| measures the local volume scaling factor, and AA is invertible if and only if det⁡(A)≠0\det(A) \ne 0 (equivalently, all eigenvalues λi≠0\lambda_i \ne 0).

Coordinate transformation grid showing object and transformed image: Matrices, Linear Layers & Activation Functions — Linear Transformation & Basis Action-6-4-226-6-4-2246PQRP′Q′R′Linear Transformation & Basis Action
Coordinate grid showing geometric action of a linear transformation mapping △ABC to its image △A'B'C'.
⊙ Explorer · Dense Layer & Two-Neuron ReLU Universal Function Approximator
interactive
Hinge Activation Kinksx1=−0.67,x2=1.00x_{1} = -0.67, x_{2} = 1.00
Output h(2)h(2) = ReLU(z1)(z_{1}) − ReLU(z2)(z_{2})h(2)=2.50h(2) = 2.50
Active Linear Regime2 Active Hinges

See how a hidden layer combining piecewise-linear ReLU activations max⁡(0,wi⋅x+bi)\max(0, w_i \cdot x + b_i) creates hinged bends capable of approximating nonlinear functions.

Scatter plot1123442542597794111(1, 35)(2, 57)(3, 79)(4, 101)
Matrices, Linear Layers & Activation Functions — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Matrices, Linear Layers & Activation Functions.
ReLU
ReLU(z)=max⁡(0,z) \text{ReLU}(z) = \max(0, z)
Sigmoid
σ(z)=11+e−z∈(0,1) \sigma(z) = \frac{1}{1 + e^{-z}} \in (0, 1)
Softmax
Softmax(zi)=ezi∑jezj \text{Softmax}(z_i) = \frac{e^{z_i}}{\sum_j e^{z_j}}
Matrix Dimension Rule
(m×k)⋅(k×n)=(m×n) (m \times k) \cdot (k \times n) = (m \times n)
◆ Why It Works — First-Principles Derivation (Matrices, Linear Layers & Activation Functions)

Why Orthogonal Projection & Eigenvalue Characteristic Equations Work: Decompose u=cv+w\mathbf{u} = c\mathbf{v} + \mathbf{w} where w⊥v\mathbf{w} \perp \mathbf{v}. Taking the dot product with v\mathbf{v} uses w⋅v=0\mathbf{w}\cdot\mathbf{v} = 0 to isolate cc:

u⋅v=c(v⋅v)+0  ⟹  c=u⋅v∥v∥2 \mathbf{u}\cdot\mathbf{v} = c(\mathbf{v}\cdot\mathbf{v}) + 0 \implies c = \frac{\mathbf{u}\cdot\mathbf{v}}{\|\mathbf{v}\|^2}

For eigenvalues, Av=λvA\mathbf{v} = \lambda\mathbf{v} with v≠0\mathbf{v} \ne \mathbf{0} is equivalent to (A−λI)v=0(A - \lambda I)\mathbf{v} = \mathbf{0}. A homogeneous linear system has a non-trivial nullspace vector v≠0\mathbf{v} \ne \mathbf{0} if and only if the matrix A−λIA - \lambda I is singular, yielding the characteristic polynomial det⁡(A−λI)=0\det(A - \lambda I) = 0.

Worked Example 2.A — Manual Feedforward Neural Layer

A neural network layer has 2 inputs and 3 neurons with weights and biases:
W=(2−10.53−11),b=(1−20.5) \mathbf{W} = \begin{pmatrix} 2 & -1 \\ 0.5 & 3 \\ -1 & 1 \end{pmatrix}, \quad \mathbf{b} = \begin{pmatrix} 1 \\ -2 \\ 0.5 \end{pmatrix}
For the input x=(32) \mathbf{x} = \begin{pmatrix} 3 \\ 2 \end{pmatrix} , compute the pre-activation z \mathbf{z} and the activated output a \mathbf{a} using the ReLU function.

Solution:
Compute Wx \mathbf{W}\mathbf{x} :
Wx=(2(3)+(−1)(2)0.5(3)+3(2)−1(3)+1(2))=(6−21.5+6−3+2)=(47.5−1) \mathbf{W}\mathbf{x} = \begin{pmatrix} 2(3) + (-1)(2) \\ 0.5(3) + 3(2) \\ -1(3) + 1(2) \end{pmatrix} = \begin{pmatrix} 6 - 2 \\ 1.5 + 6 \\ -3 + 2 \end{pmatrix} = \begin{pmatrix} 4 \\ 7.5 \\ -1 \end{pmatrix}
Add bias vector b \mathbf{b} :
z=(47.5−1)+(1−20.5)=(55.5−0.5) \mathbf{z} = \begin{pmatrix} 4 \\ 7.5 \\ -1 \end{pmatrix} + \begin{pmatrix} 1 \\ -2 \\ 0.5 \end{pmatrix} = \begin{pmatrix} 5 \\ 5.5 \\ -0.5 \end{pmatrix}
Apply element-wise ReLU(z)=max⁡(0,z) \text{ReLU}(z) = \max(0, z) :
a=ReLU(z)=(max⁡(0,5)max⁡(0,5.5)max⁡(0,−0.5))=(55.50) \mathbf{a} = \text{ReLU}(\mathbf{z}) = \begin{pmatrix} \max(0, 5) \\ \max(0, 5.5) \\ \max(0, -0.5) \end{pmatrix} = \begin{pmatrix} 5 \\ 5.5 \\ 0 \end{pmatrix} .
Answer: z=[5,5.5,−0.5]T \mathbf{z} = [5, 5.5, -0.5]^T , a=[5,5.5,0]T \mathbf{a} = [5, 5.5, 0]^T .

Worked Example BB — Matrices, Linear Layers & Activation Functions (Medium Application)

Problem (Medium): In a multiple linear regression model, the Sum of Squared Errors is SSE=100 \text{SSE} = 100 and the Total Sum of Squares is SST=500 \text{SST} = 500 . What is the coefficient of determination R2 R^2 ?

Step-by-Step Solution: The coefficient of determination measures the proportion of variance explained: R2=1−SSESST=1−100500=1−0.20=0.80 R^2 = 1 - \frac{\text{SSE}}{\text{SST}} = 1 - \frac{100}{500} = 1 - 0.20 = 0.80 .

Worked Example CC — Matrices, Linear Layers & Activation Functions (Hard Application)

Problem (Hard): A centered feature matrix X \mathbf{X} has shape N×38 N \times 38 . What is the size and symmetry property of the sample covariance matrix Σ=1N−1XTX \mathbf{\Sigma} = \frac{1}{N-1}\mathbf{X}^T\mathbf{X} ?

Step-by-Step Solution: Since X \mathbf{X} has 38 38 columns, XT \mathbf{X}^T is 38×N 38 \times N and XTX \mathbf{X}^T\mathbf{X} is 38×38 38 \times 38 . Furthermore, (XTX)T=XT(XT)T=XTX (\mathbf{X}^T\mathbf{X})^T = \mathbf{X}^T(\mathbf{X}^T)^T = \mathbf{X}^T\mathbf{X} , proving it is always symmetric.

Worked Example DD — Matrices, Linear Layers & Activation Functions (Easy Application)

Problem (Easy): Consider a linear layer with a weight matrix W W and an input vector x \mathbf{x} . If W=(1234) W = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} and x=(56) \mathbf{x} = \begin{pmatrix} 5 \\ 6 \end{pmatrix} , compute the output vector y=Wx \mathbf{y} = W\mathbf{x} .

Step-by-Step Solution: The output vector y \mathbf{y} is computed by multiplying the weight matrix W W by the input vector x \mathbf{x} . This is a standard matrix-vector multiplication. \\ \\ y=Wx=(1234)(56) \mathbf{y} = W\mathbf{x} = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} 5 \\ 6 \end{pmatrix} \\\ \\ To compute the first element of y \mathbf{y} , we take the dot product of the first row of W W with x \mathbf{x} : (1)(5)+(2)(6)=5+12=17 (1)(5) + (2)(6) = 5 + 12 = 17 .\\ \\ To compute the second element of y \mathbf{y} , we take the dot product of the second row of W W with x \mathbf{x} : (3)(5)+(4)(6)=15+24=39 (3)(5) + (4)(6) = 15 + 24 = 39 .\\ \\ Therefore, the output vector is y=(1739) \mathbf{y} = \begin{pmatrix} 17 \\ 39 \end{pmatrix} .

⚠️ Common Exam Traps — Matrices, Linear Layers & Activation Functions

1. Non-Commutativity of Matrix Multiplication & Cross Products: On Mathematics for Artificial Intelligence & Machine Learning, assuming AB=BAAB = BA (so expanding (A+B)2(A+B)^2 as A2+2AB+B2A^2 + 2AB + B^2 instead of A2+AB+BA+B2A^2 + AB + BA + B^2) or forgetting u×v=−(v×u)\mathbf{u}\times\mathbf{v} = -(\mathbf{v}\times\mathbf{u}) invalidates matrix proofs.

2. Using Position Vectors Instead of Direction Vectors for Angles: To find the angle at vertex BB of triangle ABCABC, you must use tail-to-tail vectors BA→\overrightarrow{BA} and BC→\overrightarrow{BC}, never AB→⋅BC→\overrightarrow{AB}\cdot\overrightarrow{BC} (which finds the exterior supplementary angle 180∘−B180^\circ - B).

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Matrices, Linear Layers & Activation Functions)
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Computing angle at BB using AB→⋅BC→\overrightarrow{AB}\cdot\overrightarrow{BC} Vectors are head-to-tail instead of tail-to-tail, giving 180∘−θ180^\circ - \theta. Reverse AB→\overrightarrow{AB} so both emanate from BB: use BA→⋅BC→\overrightarrow{BA}\cdot\overrightarrow{BC}.
Using the same parameter tt for two intersecting 3D lines r1(t)=r2(t)\mathbf{r}_1(t) = \mathbf{r}_2(t) Tests for a simultaneous collision at time tt rather than geometric intersection of paths. Assign distinct parameters λ\lambda and μ\mu to the two lines before equating components.
Assuming (AB)−1=A−1B−1(AB)^{-1} = A^{-1}B^{-1} Multiplying (AB)(A−1B−1)(AB)(A^{-1}B^{-1}) does not cancel inner factors when AB≠BAAB \ne BA. Use the shoe-sock reversal law: (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1}.
▲ Exam Pacing & Verification Strategy — Matrices, Linear Layers & Activation Functions

Fast Matrix & Vector Verification (Mathematics for Artificial Intelligence & Machine Learning): Check every 2×22\times 2 or 3×33\times 3 eigenvalue computation using the trace and determinant invariants: ∑λi=tr⁡(A)\sum \lambda_i = \operatorname{tr}(A) (sum of diagonal entries) and ∏λi=det⁡(A)\prod \lambda_i = \det(A).

[Practice 1 · Medium] A 3D dataset has covariance matrix eigenvalues λ1=62 \lambda_1 = 62 , λ2=24 \lambda_2 = 24 , and λ3=14 \lambda_3 = 14 . What percentage of total variance is explained by the first principal component PC1 PC_1 ?
💡 Hint 1 of 3
Total variance is ∑λi=62+24+14\sum \lambda_i = 62 + 24 + 14.
💡 Hint 2 of 3
The proportion explained by PC1 PC_1 is: λ1∑λi\frac{\lambda_1}{\sum \lambda_i}. Rewrite and substitute: λ1∑λi=62100\frac{\lambda_1}{\sum \lambda_i} = \frac{62}{100}.
💡 Hint 3 of 3
Evaluate 62100\frac{62}{100} to obtain the final answer.
Total variance is ∑λi=62+24+14=100 \sum \lambda_i = 62 + 24 + 14 = 100 . The proportion explained by PC1 PC_1 is λ1∑λi=62100=62.0% \frac{\lambda_1}{\sum \lambda_i} = \frac{62}{100} = 62.0\% .
[Practice 2 · Hard] Consider a dataset with two features, X1 X_1 and X2 X_2 . The covariance matrix for this dataset is given by: Σ=(105520) \Sigma = \begin{pmatrix} 10 & 5 \\ 5 & 20 \end{pmatrix} What is the variance of the first feature, X1 X_1 ?
💡 Hint 1 of 3
The covariance matrix Σ \Sigma for a dataset with two features X1 X_1 and X2 X_2 is structured as follows: Σ=(Cov(X1,X1)Cov(X1,X2)Cov(X2,X1)Cov(X2,X2))\Sigma = \begin{pmatrix} Cov(X_1, X_1) & Cov(X_1, X_2) \\ Cov(X_2, X_1) & Cov(X_2, X_2) \end{pmatrix}.
💡 Hint 2 of 3
By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1) Var(X_1) = Cov(X_1, X_1) and Var(X2)=Cov(X2,X2) Var(X_2) = Cov(X_2, X_2) . In the given covariance matrix: Σ=(105520)\Sigma = \begin{pmatrix} 10 & 5 \\ 5 & 20 \end{pmatrix}.
💡 Hint 3 of 3
Thus, the variance of X1X_1 is 10. The covariance between X1X_1 and X2X_2 is 5, and the variance of X2X_2 is 20.
The covariance matrix Σ \Sigma for a dataset with two features X1 X_1 and X2 X_2 is structured as follows: Σ=(Cov(X1,X1)Cov(X1,X2)Cov(X2,X1)Cov(X2,X2)) \Sigma = \begin{pmatrix} Cov(X_1, X_1) & Cov(X_1, X_2) \\ Cov(X_2, X_1) & Cov(X_2, X_2) \end{pmatrix} By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1) Var(X_1) = Cov(X_1, X_1) and Var(X2)=Cov(X2,X2) Var(X_2) = Cov(X_2, X_2) . In the given covariance matrix: Σ=(105520) \Sigma = \begin{pmatrix} 10 & 5 \\ 5 & 20 \end{pmatrix} The element in the first row and first column represents Cov(X1,X1) Cov(X_1, X_1) , which is the variance of X1 X_1 . Thus, the variance of X1 X_1 is 10. The covariance between X1 X_1 and X2 X_2 is 5, and the variance of X2 X_2 is 20.
[Practice 3 · Easy] Principal Component Analysis (PCA) projects a dataset from R50 \mathbb{R}^{50} onto its top 6 6 principal components. What is the dimension of each transformed data point?
💡 Hint 1 of 3
PCA projection onto k k eigenvectors transforms each sample vector from RD \mathbb{R}^D to Rk \mathbb{R}^k .
💡 Hint 2 of 3
Here k=6 k = 6 .
💡 Hint 3 of 3
So the reduced dimension is 66.
PCA projection onto k k eigenvectors transforms each sample vector from RD \mathbb{R}^D to Rk \mathbb{R}^k . Here k=6 k = 6 , so the reduced dimension is 6 6 .
[Practice 4 · Medium] A vector v \mathbf{v} is transformed into a new vector v′ \mathbf{v}' by a linear transformation represented by the matrix M \mathbf{M} . We are given that v=(2 3) \mathbf{v} = \begin{pmatrix} 2 \ 3 \end{pmatrix} and v′=(7 11) \mathbf{v}' = \begin{pmatrix} 7 \ 11 \end{pmatrix} . The transformation matrix is of the form M=(a1 4b) \mathbf{M} = \begin{pmatrix} a & 1 \ 4 & b \end{pmatrix} . Determine the value of a a and b b .
💡 Hint 1 of 3
The transformation is defined by v′=Mv \mathbf{v}' = \mathbf{M}\mathbf{v} . Substituting the given vectors and matrix form: (7 11)=(a1 4b)(2 3) \begin{pmatrix} 7 \ 11 \end{pmatrix} = \begin{pmatrix} a & 1 \ 4 & b \end{pmatrix} \begin{pmatrix} 2 \ 3 \end{pmatrix} .
💡 Hint 2 of 3
Performing the matrix multiplication: (7 11)=(2a+3 8+3b) \begin{pmatrix} 7 \ 11 \end{pmatrix} = \begin{pmatrix} 2a + 3 \ 8 + 3b \end{pmatrix} Equating the corresponding components, we get a system of two linear equations: 1) 2a+3=7 2a + 3 = 7 .
💡 Hint 3 of 3
Solving the second equation for bb: 3b=11−83b = 11 - 8.
The transformation is defined by v′=Mv \mathbf{v}' = \mathbf{M}\mathbf{v} . Substituting the given vectors and matrix form: (7 11)=(a1 4b)(2 3) \begin{pmatrix} 7 \ 11 \end{pmatrix} = \begin{pmatrix} a & 1 \ 4 & b \end{pmatrix} \begin{pmatrix} 2 \ 3 \end{pmatrix} Performing the matrix multiplication: (7 11)=(2a+3 8+3b) \begin{pmatrix} 7 \ 11 \end{pmatrix} = \begin{pmatrix} 2a + 3 \ 8 + 3b \end{pmatrix} Equating the corresponding components, we get a system of two linear equations: 1) 2a+3=7 2a + 3 = 7 2) 8+3b=11 8 + 3b = 11 Solving the first equation for a a : 2a=7−3 2a = 7 - 3 2a=4 2a = 4 a=2 a = 2 Solving the second equation for b b : 3b=11−8 3b = 11 - 8 3b=3 3b = 3 b=1 b = 1 Thus, a=2 a = 2 and b=1 b = 1 .
[Practice 5 · Hard] A medical test for a rare disease has a 99\% accuracy rate in detecting the disease when it is present (True Positive Rate) and a 95\% accuracy rate in identifying individuals without the disease (True Negative Rate). If the prevalence of the disease in the population is 0.5\%, what is the probability that a person who tests positive actually has the disease?
💡 Hint 1 of 3
Let D be the event that a person has the disease, and P be the event that the person tests positive.
💡 Hint 2 of 3
We are given: P(P|D) = 0.99 (True Positive Rate) P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate).
💡 Hint 3 of 3
Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.
Let D be the event that a person has the disease, and P be the event that the person tests positive. We are given: P(P|D) = 0.99 (True Positive Rate) P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate) P(D) = 0.005 (Prevalence of the disease) From P(D), we know P(not D) = 1 - P(D) = 1 - 0.005 = 0.995. We want to find P(D|P), the probability that a person has the disease given a positive test result. Using Bayes' Theorem: P(D|P) = [P(P|D) * P(D)] / P(P) To find P(P), we use the law of total probability: P(P) = P(P|D) * P(D) + P(P|not D) * P(not D) P(P) = (0.99 * 0.005) + (0.05 * 0.995) P(P) = 0.00495 + 0.04975 P(P) = 0.0547 Now, substitute this back into Bayes' Theorem: P(D|P) = (0.99 * 0.005) / 0.0547 P(D|P) = 0.00495 / 0.0547 P(D|P) \approx 0.09049 Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.
📝 Chapter Quiz
3

Loss Functions, Gradients & Optimization

🤖 AI Math Unit 3 — Gradient Descent Optimization Applied STEM  ·  Loss functions: Mean Squared Error (MSE)  ·  Partial derivatives & the gradient vector ∇L  ·  Learning rate η and convergence  ·  Gradient descent update rule w ← w - η ∇L  ·  Convex vs non-convex loss landscapes

Machine learning models learn by minimizing a loss function via gradient descent. Calculus provides the directional derivative pointing toward the steepest descent in parameter space.

▲ Theorem 3.1 — Gradient Descent Update Equation
Let L(w) L(\mathbf{w}) be a differentiable loss function over weight parameters w \mathbf{w} . The gradient ∇L(w)=[∂L∂w1,…,∂L∂wd]T \nabla L(\mathbf{w}) = \left[ \frac{\partial L}{\partial w_1}, \dots, \frac{\partial L}{\partial w_d} \right]^T points in the direction of greatest rate of increase.
To minimize loss, parameter updates step in the opposite direction scaled by learning rate η>0 \eta > 0 :
wt+1=wt−η∇L(wt) \mathbf{w}_{t+1} = \mathbf{w}_t - \eta \nabla L(\mathbf{w}_t)
● Deep Conceptual Intuition — Loss Functions, Gradients & Optimization

Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔyΔxm = \dfrac{\Delta y}{\Delta x}, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1a_1 x + b_1 y = c_1, a2x+b2y=c2a_2 x + b_2 y = c_2 has a unique intersection if a1a2≠b1b2\dfrac{a_1}{a_2} \ne \dfrac{b_1}{b_2}, no solution (parallel lines) if a1a2=b1b2≠c1c2\dfrac{a_1}{a_2} = \dfrac{b_1}{b_2} \ne \dfrac{c_1}{c_2}, and infinitely many solutions if all three ratios coincide.

Loss Functions, Gradients & Optimization — Linear System Intersection & Equilibrium — Coordinate plane with graph of y = x + 4, y = −2x + 7; marked points (1, 5) (1, 5)Linear System Intersection & Equilibrium-3-2-11234-2246xy(1, 5)y = x + 4y = −2x + 7
Coordinate intersection of linear system y=2x+1y = 2x + 1 and y=−x+7y = -x + 7 at unique equilibrium point (2,5)(2, 5).
⊙ Explorer · Gradient Descent Optimization w_{t+1} = wt−ηw_t - \eta·∇L(wt)L(w_t)
interactive
Initial Gradient ∇L(w0)L(w_{0})∇L(w0)=−7.00∇L(w_{0}) = -7.00
Weight w6w_{6} after 6 Stepsw6=0.997w_{6} = 0.997
Convergence RegimeMonotone Convergent

Trace 6 steps of gradient descent w_{t+1} = wt−η⋅2(wt−1)w_t - \eta \cdot 2(w_t - 1) on the convex loss bowl L(w)=(w−1)2+0.5L(w) = (w - 1)^{2} + 0.5. Notice how η>0.5\eta > 0.5 overshoots the minimum and η≥1.0\eta \ge 1.0 diverges!

Coordinate plane with graph of y = 0.5(x-22)² + 2202224262830323451015xy
Loss Functions, Gradients & Optimization — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Loss Functions, Gradients & Optimization.
MSE Loss
MSE=1N∑i=1N(yi−y^i)2 \text{MSE} = \frac{1}{N}\sum_{i=1}^N (y_i - \hat{y}_i)^2
Gradient Vector
∇L=[∂L∂w,∂L∂b]T \nabla L = \left[ \frac{\partial L}{\partial w}, \frac{\partial L}{\partial b} \right]^T
Learning Rate
Too high: divergence/oscillation. Too low: slow convergence.
Stochastic GD
Updates weights on mini-batches of size B≪N B \ll N .
◆ Why It Works — First-Principles Derivation (Loss Functions, Gradients & Optimization)

Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0Q_0 undergoes a percentage change p%p\% followed by q%q\%, the compound multiplier is the product of individual scale factors:

Qfinal=Q0(1+p100) ⁣(1+q100)=Q0(1+p+q100+pq10000) Q_{\text{final}} = Q_0\left(1 + \frac{p}{100}\right)\!\left(1 + \frac{q}{100}\right) = Q_0\left(1 + \frac{p + q}{100} + \frac{pq}{10000}\right)

Notice the cross term pq10000\dfrac{pq}{10000}: an increase of p%p\% followed by a decrease of p%p\% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).

Worked Example 3.A — Single Step of Gradient Descent

Consider a simple linear model y^=wx \hat{y} = wx with squared loss for a single data point (x,y)=(2,8) (x, y) = (2, 8) :
L(w)=(y−wx)2=(8−2w)2 L(w) = (y - wx)^2 = (8 - 2w)^2
If the current weight is w0=1.0 w_0 = 1.0 and the learning rate is η=0.05 \eta = 0.05 , compute the gradient dLdw \frac{dL}{dw} and the updated weight w1 w_1 .

Solution:
Apply the chain rule to differentiate L(w) L(w) :
dLdw=2(8−2w)⋅(−2)=−4(8−2w)=−32+8w \frac{dL}{dw} = 2(8 - 2w) \cdot (-2) = -4(8 - 2w) = -32 + 8w
Evaluate at w0=1.0 w_0 = 1.0 :
dLdw∣w=1.0=−32+8(1)=−24 \left.\frac{dL}{dw}\right|_{w=1.0} = -32 + 8(1) = -24
Apply gradient descent update:
w1=w0−η(dLdw)=1.0−(0.05)(−24)=1.0+1.2=2.2 w_1 = w_0 - \eta \left(\frac{dL}{dw}\right) = 1.0 - (0.05)(-24) = 1.0 + 1.2 = 2.2 .
Notice that with w0=1.0 w_0 = 1.0 , prediction y^=2 \hat{y} = 2 was too low (target was 8). The gradient step increased w w to 2.2, giving y^=4.4 \hat{y} = 4.4 , moving closer to 8.
Answer: Gradient = −24 -24 ; updated weight w1=2.2 w_1 = 2.2 .

Worked Example BB — Loss Functions, Gradients & Optimization (Medium Application)

Problem (Medium): Consider a univariate regression model where the predicted output y^ \hat{y} is given by y^=ax+b \hat{y} = ax + b . The loss function is the Mean Squared Error (MSE), defined as L=1n∑i=1n(yi−y^i)2 L = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2 . For a single data point (x1,y1)=(2,5) (x_1, y_1) = (2, 5) , the loss is L=(5−(2a+b))2 L = (5 - (2a + b))^2 . The gradient of the loss function with respect to a a is ∂L∂a=−2(5−(2a+b))⋅2 \frac{\partial L}{\partial a} = -2(5 - (2a + b)) \cdot 2 . If during gradient descent, with a learning rate of η=0.1 \eta = 0.1 , the parameters a a and b b are updated from aold=1 a_{old} = 1 and bold=1 b_{old} = 1 , to anew=0.8 a_{new} = 0.8 and bnew=0.8 b_{new} = 0.8 , what is the value of b b that would have resulted in ∂L∂b=0 \frac{\partial L}{\partial b} = 0 for this single data point, assuming a=1 a=1 and b=1 b=1 were the values *before* the gradient calculation that led to the update to anew=0.8,bnew=0.8 a_{new}=0.8, b_{new}=0.8 ?

Step-by-Step Solution: The loss function for a single data point is L=(y1−(ax1+b))2 L = (y_1 - (ax_1 + b))^2 . Given (x1,y1)=(2,5) (x_1, y_1) = (2, 5) , so L=(5−(2a+b))2 L = (5 - (2a + b))^2 . The gradient of the loss with respect to b b is ∂L∂b=2(5−(2a+b))⋅(−1)=−2(5−2a−b) \frac{\partial L}{\partial b} = 2(5 - (2a + b)) \cdot (-1) = -2(5 - 2a - b) . We are asked to find the value of b b for which ∂L∂b=0 \frac{\partial L}{\partial b} = 0 , assuming a=1 a=1 and b=1 b=1 were the parameters *before* the update step that led to anew=0.8,bnew=0.8 a_{new}=0.8, b_{new}=0.8 . This means we evaluate the gradient at a=1 a=1 and the *unknown* value of b b . Setting ∂L∂b=0 \frac{\partial L}{\partial b} = 0 : −2(5−2(1)−b)=0 -2(5 - 2(1) - b) = 0 5−2−b=0 5 - 2 - b = 0 3−b=0 3 - b = 0 b=3 b = 3 . The provided gradient update information ∂L∂a=−2(5−(2a+b))⋅2 \frac{\partial L}{\partial a} = -2(5 - (2a + b)) \cdot 2 and the learning rate η=0.1 \eta = 0.1 are distractors. The question specifically asks for the value of b b that makes ∂L∂b=0 \frac{\partial L}{\partial b} = 0 *at the point where a=1 a=1 *. The update rule to anew=0.8,bnew=0.8 a_{new}=0.8, b_{new}=0.8 implies that the gradient of a a was aold−anewη=1−0.80.1=2 \frac{a_{old} - a_{new}}{\eta} = \frac{1 - 0.8}{0.1} = 2 , and the gradient of b b was bold−bnewη=1−0.80.1=2 \frac{b_{old} - b_{new}}{\eta} = \frac{1 - 0.8}{0.1} = 2 . Let's verify: If a=1 a=1 and b=3 b=3 , then ∂L∂b=−2(5−2(1)−3)=−2(5−2−3)=−2(0)=0 \frac{\partial L}{\partial b} = -2(5 - 2(1) - 3) = -2(5 - 2 - 3) = -2(0) = 0 . If a=1 a=1 and b=3 b=3 , ∂L∂a=−2(5−2(1)−3)⋅2=−2(0)⋅2=0 \frac{\partial L}{\partial a} = -2(5 - 2(1) - 3) \cdot 2 = -2(0) \cdot 2 = 0 . This scenario implies that the point a=1,b=3 a=1, b=3 is a minimum for the loss function, but the question is about finding the value of b b that makes the gradient of b b zero at a=1 a=1 , which is b=3 b=3 . The provided update anew=0.8,bnew=0.8 a_{new}=0.8, b_{new}=0.8 from aold=1,bold=1 a_{old}=1, b_{old}=1 is a different step in the optimization process and is not directly used to find the value of b b that makes the gradient of b b zero at a=1 a=1 .

Worked Example CC — Loss Functions, Gradients & Optimization (Hard Application)

Problem (Hard): Consider the following quadratic loss function for a regression problem: L(y,y^)=(y−y^)2 L(y, \hat{y}) = (y - \hat{y})^2 . If the predicted value y^=5 \hat{y} = 5 and the true value y=3 y = 3 , what is the value of the loss function?

Step-by-Step Solution: The quadratic loss function is defined as L(y,y^)=(y−y^)2 L(y, \hat{y}) = (y - \hat{y})^2 . Given the true value y=3 y = 3 and the predicted value y^=5 \hat{y} = 5 , we substitute these values into the loss function: L(3,5)=(3−5)2 L(3, 5) = (3 - 5)^2 L(3,5)=(−2)2 L(3, 5) = (-2)^2 L(3,5)=4 L(3, 5) = 4 Therefore, the value of the loss function is 4.

Worked Example DD — Loss Functions, Gradients & Optimization (Easy Application)

Problem (Easy): Consider the quadratic loss function L(w)=w2−4w+3 L(w) = w^2 - 4w + 3 . Find the value of w w where the function reaches its minimum.

Step-by-Step Solution: The given loss function is a quadratic function L(w)=w2−4w+3 L(w) = w^2 - 4w + 3 . This represents a parabola opening upwards. The minimum value of a quadratic function of the form aw2+bw+c aw^2 + bw + c occurs at w=−b2a w = -\frac{b}{2a} . In this case, a=1 a = 1 and b=−4 b = -4 . Therefore, the minimum occurs at w=−−42(1)=42=2 w = -\frac{-4}{2(1)} = \frac{4}{2} = 2 . Alternatively, we can find the minimum by taking the derivative and setting it to zero: L′(w)=2w−4 L'(w) = 2w - 4 . Setting L′(w)=0 L'(w) = 0 gives 2w−4=0 2w - 4 = 0 , which implies 2w=4 2w = 4 , so w=2 w = 2 .

⚠️ Common Exam Traps — Loss Functions, Gradients & Optimization

1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20%20\% discount followed by a 20%20\% increase gives 0.80×1.20=0.960.80 \times 1.20 = 0.96 (a net 4%4\% loss, not 0%0\%). Likewise, average speed for a round trip at 4040 and 60 km/h60\text{ km/h} is 2(40)(60)100=48 km/h\dfrac{2(40)(60)}{100} = 48\text{ km/h}, never 50 km/h50\text{ km/h}.

2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −3x+5≤8-3x + 5 \le 8, dividing by −3-3 strictly reverses ≤\le to ≥\ge.

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Loss Functions, Gradients & Optimization)
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Claiming +25%+25\% followed by −25%-25\% returns to 100%100\% The 25%25\% reduction applies to the larger base 1.25Q01.25 Q_0, not Q0Q_0. Multiply scale factors: 1.25×0.75=0.93751.25 \times 0.75 = 0.9375 (a 6.25%6.25\% net decrease).
Solving −3x>12-3x > 12 as x>−4x > -4 Dividing by a negative number reverses order on the real number line. Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).
Computing round-trip average speed as v1+v22\frac{v_1 + v_2}{2} Time spent at the slower speed is longer than time spent at the faster speed. Use total distance over total time: vavg=2v1v2v1+v2v_{\text{avg}} = \frac{2v_1 v_2}{v_1 + v_2}.
▲ Exam Pacing & Verification Strategy — Loss Functions, Gradients & Optimization

High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y3x + 3y rather than xx and yy individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.

[Practice 1 · Medium] Consider the following quadratic loss function: L(w)=3w2−12w+10 L(w) = 3w^2 - 12w + 10 . What is the value of w w that minimizes this loss function?
💡 Hint 1 of 3
To find the minimum of the quadratic loss function L(w)=3w2−12w+10 L(w) = 3w^2 - 12w + 10 , we can find the derivative with respect to w w and set it to zero.
💡 Hint 2 of 3
The derivative of L(w) L(w) with respect to w w is: dLdw=6w−12 \frac{dL}{dw} = 6w - 12 . Setting the derivative to zero to find the critical point: 6w−12=0 6w - 12 = 0 6w=12 6w = 12 w=126 w = \frac{12}{6} w=2 w = 2 .
💡 Hint 3 of 3
The second derivative is d2Ldw2=6\frac{d^2L}{dw^2} = 6, which is positive, confirming that ww corresponds to a minimum.
To find the minimum of the quadratic loss function L(w)=3w2−12w+10 L(w) = 3w^2 - 12w + 10 , we can find the derivative with respect to w w and set it to zero. The derivative of L(w) L(w) with respect to w w is: dLdw=6w−12 \frac{dL}{dw} = 6w - 12 . Setting the derivative to zero to find the critical point: 6w−12=0 6w - 12 = 0 6w=12 6w = 12 w=126 w = \frac{12}{6} w=2 w = 2 . The second derivative is d2Ldw2=6 \frac{d^2L}{dw^2} = 6 , which is positive, confirming that w=2 w=2 corresponds to a minimum.
[Practice 2 · Hard] Evaluate the output of the standard ReLU activation function f(z)=max⁡(0,z) f(z) = \max(0, z) for inputs z1=−4 z_1 = -4 and z2=6 z_2 = 6 .
💡 Hint 1 of 3
By definition of the Rectified Linear Unit: ReLU(z)=z \text{ReLU}(z) = z if z>0 z > 0 .
💡 Hint 2 of 3
And 0 0 if z≤0 z \le 0 .
💡 Hint 3 of 3
Thus f(−4)=0f(-4) = 0 and f(6)f(6).
By definition of the Rectified Linear Unit: ReLU(z)=z \text{ReLU}(z) = z if z>0 z > 0 , and 0 0 if z≤0 z \le 0 . Thus f(−4)=0 f(-4) = 0 and f(6)=6 f(6) = 6 .
[Practice 3 · Easy] In gradient descent, a weight currently has value w=60 w = 60 . If the gradient of the loss is ∂L∂w=24 \frac{\partial L}{\partial w} = 24 and the learning rate is η=0.6 \eta = 0.6 , find the updated weight w′ w' .
💡 Hint 1 of 3
Using the gradient descent update rule: w′=w−η∂L∂ww' = w - \eta \frac{\partial L}{\partial w}.
💡 Hint 2 of 3
Substitute and simplify: w′=60−(0.6)(24)w' = 60 - (0.6)(24).
💡 Hint 3 of 3
Compute the final value from: 60−14.4060 - 14.40.
Using the gradient descent update rule: w′=w−η∂L∂w=60−(0.6)(24)=60−14.40=45.60 w' = w - \eta \frac{\partial L}{\partial w} = 60 - (0.6)(24) = 60 - 14.40 = 45.60 .
[Practice 4 · Medium] Consider the scalar loss function L(w)=5w2−8w+5 L(w) = 5w^2 - 8w + 5 . Find the analytical gradient ∇L(w) \nabla L(w) evaluated at w=8 w = 8 .
💡 Hint 1 of 3
Differentiate with respect to w w : dLdw=2(5)w−8=10w−8 \frac{dL}{dw} = 2(5)w - 8 = 10w - 8 .
💡 Hint 2 of 3
At w=8 w = 8 : ∇L=10(8)−8\nabla L = 10(8) - 8. Substitute and simplify: ∇L=80−8\nabla L = 80 - 8.
💡 Hint 3 of 3
Compute the final value from: 80−880 - 8.
Differentiate with respect to w w : dLdw=2(5)w−8=10w−8 \frac{dL}{dw} = 2(5)w - 8 = 10w - 8 . At w=8 w = 8 : ∇L=10(8)−8=80−8=72 \nabla L = 10(8) - 8 = 80 - 8 = 72 .
[Practice 5 · Hard] Two document embeddings a=[6,12]T \mathbf{a} = [6, 12]^T and b=[12,6]T \mathbf{b} = [12, 6]^T are compared. If ∥a∥=∥b∥=180 \|\mathbf{a}\| = \|\mathbf{b}\| = \sqrt{180} , calculate their exact cosine similarity.
💡 Hint 1 of 3
Dot product a⋅b=(6)(12)+(12)(6)\mathbf{a} \cdot \mathbf{b} = (6)(12) + (12)(6).
💡 Hint 2 of 3
Product of norms ∥a∥∥b∥=180 \|\mathbf{a}\| \|\mathbf{b}\| = 180 .
💡 Hint 3 of 3
Cosine similarity = 144180\frac{144}{180}.
Dot product a⋅b=(6)(12)+(12)(6)=144 \mathbf{a} \cdot \mathbf{b} = (6)(12) + (12)(6) = 144 . Product of norms ∥a∥∥b∥=180 \|\mathbf{a}\| \|\mathbf{b}\| = 180 . Cosine similarity = 144180=0.800 \frac{144}{180} = 0.800 .
📝 Chapter Quiz
4

Conditional Probability, Bayes' Rule & Classifiers

🤖 AI Math Unit 4 — Probabilistic Machine Learning Applied STEM  ·  Joint and conditional probability P(A|B)  ·  Bayes' Theorem: Prior, Likelihood, Posterior  ·  Total probability theorem  ·  Naive Bayes independence assumption  ·  Text spam filtering & medical diagnostics

Uncertainty is omnipresent in real-world data. Bayes' Theorem provides the mathematical framework for updating beliefs when observing new evidence, forming the core of Bayesian machine learning and Naive Bayes classifiers.

▲ Theorem 4.1 — Bayes' Theorem in Machine Learning
For hypothesis (class) C C and observed evidence (features) x \mathbf{x} :
P(C∣x)=P(x∣C)P(C)P(x) P(C | \mathbf{x}) = \frac{P(\mathbf{x} | C) P(C)}{P(\mathbf{x})}
Where:
• P(C) P(C) is the Prior probability of class C C .
• P(x∣C) P(\mathbf{x} | C) is the Likelihood of observing features x \mathbf{x} given class C C .
• P(x)=∑kP(x∣Ck)P(Ck) P(\mathbf{x}) = \sum_k P(\mathbf{x}|C_k)P(C_k) is the Marginal probability (Evidence).
• P(C∣x) P(C | \mathbf{x}) is the Posterior probability.
● Deep Conceptual Intuition — Conditional Probability, Bayes' Rule & Classifiers

Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔyΔxm = \dfrac{\Delta y}{\Delta x}, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1a_1 x + b_1 y = c_1, a2x+b2y=c2a_2 x + b_2 y = c_2 has a unique intersection if a1a2≠b1b2\dfrac{a_1}{a_2} \ne \dfrac{b_1}{b_2}, no solution (parallel lines) if a1a2=b1b2≠c1c2\dfrac{a_1}{a_2} = \dfrac{b_1}{b_2} \ne \dfrac{c_1}{c_2}, and infinitely many solutions if all three ratios coincide.

Conditional Probability, Bayes' Rule & Classifiers — Linear System Intersection & Equilibrium — Coordinate plane with graph of y = x + 3, y = −x + 7; marked points (2, 5) (2, 5)Linear System Intersection & Equilibrium-2-1123452468xy(2, 5)y = x + 3y = −x + 7
Coordinate intersection of linear system y=2x+1y = 2x + 1 and y=−x+7y = -x + 7 at unique equilibrium point (2,5)(2, 5).
⊙ Explorer · Bayes' Theorem Classifier: Prior Base Rate vs. Posterior P(C1∣+)P(C_{1} | +)
interactive
Evidence Marginal P(+)P(+)P(+)=0.300P(+) = 0.300
Posterior Precision P(C1∣+)P(C_{1} | +)P(C1∣+)=60.0%P(C_{1}|+) = 60.0\%
Bayes Lift P(C1∣+)/P(C1)P(C_{1}|+) / P(C_{1})3.00× Lift

With fixed sensitivity P(+∣C1)=0.90P(+ | C_{1}) = 0.90, see how a low base rate P(C1)P(C_{1}) or high false-positive rate P(+∣C0)P(+ | C_{0}) dramatically reduces the posterior probability P(C1∣+)P(C_{1} | +).

Coordinate plane with graph of y = 0.5(x-14)² + 21214161820222451015xy
Conditional Probability, Bayes' Rule & Classifiers — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Conditional Probability, Bayes' Rule & Classifiers.
Conditional Probability
P(A∣B)=P(A∩B)P(B) P(A|B) = \frac{P(A \cap B)}{P(B)}
Naive Bayes Assumption
P(x∣C)=∏j=1dP(xj∣C) P(\mathbf{x}|C) = \prod_{j=1}^d P(x_j|C) (conditional independence)
Decision Rule
C^=arg⁡max⁡CP(C)∏j=1dP(xj∣C) \hat{C} = \arg\max_C P(C) \prod_{j=1}^d P(x_j|C)
Laplace Smoothing
Prevents zero probability: count+1total+∣V∣ \frac{\text{count} + 1}{\text{total} + |V|}
◆ Why It Works — First-Principles Derivation (Conditional Probability, Bayes' Rule & Classifiers)

Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0Q_0 undergoes a percentage change p%p\% followed by q%q\%, the compound multiplier is the product of individual scale factors:

Qfinal=Q0(1+p100) ⁣(1+q100)=Q0(1+p+q100+pq10000) Q_{\text{final}} = Q_0\left(1 + \frac{p}{100}\right)\!\left(1 + \frac{q}{100}\right) = Q_0\left(1 + \frac{p + q}{100} + \frac{pq}{10000}\right)

Notice the cross term pq10000\dfrac{pq}{10000}: an increase of p%p\% followed by a decrease of p%p\% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).

Worked Example 4.A — Bayesian Spam Classification

An email filter processes emails where 20% 20\% are spam (P(S)=0.20 P(S) = 0.20 ) and 80% 80\% are legitimate (P(L)=0.80 P(L) = 0.80 ). The word 'lottery' appears in 60% 60\% of spam emails (P(W∣S)=0.60 P(W|S) = 0.60 ) and in 1% 1\% of legitimate emails (P(W∣L)=0.01 P(W|L) = 0.01 ). If an incoming email contains the word 'lottery', what is the probability that it is spam?

Solution:
By Bayes' Theorem:
P(S∣W)=P(W∣S)P(S)P(W) P(S|W) = \frac{P(W|S)P(S)}{P(W)}
Calculate total probability P(W) P(W) :
P(W)=P(W∣S)P(S)+P(W∣L)P(L)=(0.60)(0.20)+(0.01)(0.80)=0.12+0.008=0.128 P(W) = P(W|S)P(S) + P(W|L)P(L) = (0.60)(0.20) + (0.01)(0.80) = 0.12 + 0.008 = 0.128
Compute posterior:
P(S∣W)=0.120.128=120128=1516=0.9375 P(S|W) = \frac{0.12}{0.128} = \frac{120}{128} = \frac{15}{16} = 0.9375 .
Despite only 20% of all emails being spam initially, observing the word 'lottery' raises the probability to 93.75% 93.75\% .
Answer: 93.75% 93.75\% (or 0.938 0.938 ).

Worked Example BB — Conditional Probability, Bayes' Rule & Classifiers (Medium Application)

Problem (Medium): Given n=4 n = 4 independent observations from a normal distribution with sum ∑i=14xi=12 \sum_{i=1}^{4} x_i = 12 , what is the Maximum Likelihood Estimate (MLE) μ^MLE \hat{\mu}_{\text{MLE}} ?

Step-by-Step Solution: The log-likelihood ln⁡L(μ)=−n2ln⁡(2πσ2)−12σ2∑(xi−μ)2 \ln L(\mu) = -\frac{n}{2}\ln(2\pi\sigma^2) - \frac{1}{2\sigma^2}\sum (x_i - \mu)^2 . Setting ∂ln⁡L∂μ=0 \frac{\partial \ln L}{\partial \mu} = 0 yields the sample mean μ^=1n∑xi=124=3 \hat{\mu} = \frac{1}{n}\sum x_i = \frac{12}{4} = 3 .

Worked Example CC — Conditional Probability, Bayes' Rule & Classifiers (Hard Application)

Problem (Hard): A logistic regression model produces a class probability p=P(y=1∣x)=0.40 p = P(y=1|\mathbf{x}) = 0.40 . Compute the corresponding log-odds (logit) ln⁡(p1−p) \ln\left(\frac{p}{1-p}\right) .

Step-by-Step Solution: Odds are p1−p=0.400.60=0.6667 \frac{p}{1-p} = \frac{0.40}{0.60} = 0.6667 . Taking natural logarithm: ln⁡(0.6667)=−0.405 \ln(0.6667) = -0.405 .

Worked Example DD — Conditional Probability, Bayes' Rule & Classifiers (Easy Application)

Problem (Easy): A medical diagnostic test for a rare disease is designed to be highly sensitive and specific. The disease affects 1 1 in every 1000 1000 individuals in the population. The test has a sensitivity of 99 99 \% (meaning it correctly identifies 99 99 \% of individuals who have the disease) and a specificity of 95 95 \% (meaning it correctly identifies 95 95 \% of individuals who do not have the disease). If a randomly selected individual from the population tests positive, what is the probability that they actually have the disease?

Step-by-Step Solution: Let D be the event that an individual has the disease, and P be the event that the individual tests positive. We are given the following probabilities: - Prior probability of having the disease: P(D)=11000=0.001P(D) = \frac{1}{1000} = 0.001 - Prior probability of not having the disease: P(Dc)=1−P(D)=1−0.001=0.999P(D^c) = 1 - P(D) = 1 - 0.001 = 0.999 - Sensitivity (true positive rate): P(P∣D)=0.99P(P|D) = 0.99 - Specificity (true negative rate): P(Pc∣Dc)=0.95P(P^c|D^c) = 0.95 From specificity, we can derive the false positive rate: P(P∣Dc)=1−P(Pc∣Dc)=1−0.95=0.05P(P|D^c) = 1 - P(P^c|D^c) = 1 - 0.95 = 0.05. We want to find the probability that an individual actually has the disease given a positive test result, which is P(D∣P)P(D|P). We can use Bayes' Theorem: P(D∣P)=P(P∣D)P(D)P(P)P(D|P) = \frac{P(P|D) P(D)}{P(P)} To find P(P)P(P), the overall probability of testing positive, we can use the law of total probability: P(P)=P(P∣D)P(D)+P(P∣Dc)P(Dc)P(P) = P(P|D) P(D) + P(P|D^c) P(D^c) Substitute the given values: P(P)=(0.99)(0.001)+(0.05)(0.999)P(P) = (0.99)(0.001) + (0.05)(0.999) P(P)=0.00099+0.04995P(P) = 0.00099 + 0.04995 P(P)=0.05094P(P) = 0.05094 Now, substitute P(P)P(P) back into Bayes' Theorem: P(D∣P)=(0.99)(0.001)0.05094P(D|P) = \frac{(0.99)(0.001)}{0.05094} P(D∣P)=0.000990.05094P(D|P) = \frac{0.00099}{0.05094} P(D∣P)≈0.0194346P(D|P) \approx 0.0194346 Therefore, the probability that a person who tests positive actually has the disease is approximately 0.0194 0.0194 , which is closest to 0.019 0.019 .

⚠️ Common Exam Traps — Conditional Probability, Bayes' Rule & Classifiers

1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20%20\% discount followed by a 20%20\% increase gives 0.80×1.20=0.960.80 \times 1.20 = 0.96 (a net 4%4\% loss, not 0%0\%). Likewise, average speed for a round trip at 4040 and 60 km/h60\text{ km/h} is 2(40)(60)100=48 km/h\dfrac{2(40)(60)}{100} = 48\text{ km/h}, never 50 km/h50\text{ km/h}.

2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −5x+7≤12-5x + 7 \le 12, dividing by −5-5 strictly reverses ≤\le to ≥\ge.

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Conditional Probability, Bayes' Rule & Classifiers)
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Claiming +25%+25\% followed by −25%-25\% returns to 100%100\% The 25%25\% reduction applies to the larger base 1.25Q01.25 Q_0, not Q0Q_0. Multiply scale factors: 1.25×0.75=0.93751.25 \times 0.75 = 0.9375 (a 6.25%6.25\% net decrease).
Solving −3x>12-3x > 12 as x>−4x > -4 Dividing by a negative number reverses order on the real number line. Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).
Computing round-trip average speed as v1+v22\frac{v_1 + v_2}{2} Time spent at the slower speed is longer than time spent at the faster speed. Use total distance over total time: vavg=2v1v2v1+v2v_{\text{avg}} = \frac{2v_1 v_2}{v_1 + v_2}.
▲ Exam Pacing & Verification Strategy — Conditional Probability, Bayes' Rule & Classifiers

High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y3x + 3y rather than xx and yy individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.

[Practice 1 · Medium] A spam classification model identifies TP=30 TP = 30 genuine spam emails and FP=10 FP = 10 legitimate emails falsely flagged as spam. What is the precision of this model?
💡 Hint 1 of 3
Precision is the fraction of predicted positive instances that are truly positive: Precision=TPTP+FP\text{Precision} = \frac{TP}{TP + FP}.
💡 Hint 2 of 3
Substitute and simplify: Precision=3030+10\text{Precision} = \frac{30}{30 + 10}.
💡 Hint 3 of 3
Compute the final value from: 3030+10\frac{30}{30 + 10}.
Precision is the fraction of predicted positive instances that are truly positive: Precision=TPTP+FP=3030+10=3040=75.0% \text{Precision} = \frac{TP}{TP + FP} = \frac{30}{30 + 10} = \frac{30}{40} = 75.0\% .
[Practice 2 · Hard] Compute the Manhattan (L1 L_1 ) norm and Euclidean (L2 L_2 ) norm of the word vector w=[10,−15]T \mathbf{w} = [10, -15]^T .
💡 Hint 1 of 3
Set up the initial relation: L1 L_1 norm is the sum of absolute values: ∣10∣+∣−15∣=25 |10| + |-15| = 25 .
💡 Hint 2 of 3
Rewrite and simplify to obtain: L2 L_2 norm is the square root of sum of squares: (10)2+(−15)2\sqrt{(10)^2 + (-15)^2}. Rewrite and substitute: (10)2+(−15)2=100+225\sqrt{(10)^2 + (-15)^2} = \sqrt{100 + 225}.
💡 Hint 3 of 3
Evaluate 100+225\sqrt{100 + 225} to obtain the final answer.
L1 L_1 norm is the sum of absolute values: ∣10∣+∣−15∣=25 |10| + |-15| = 25 . L2 L_2 norm is the square root of sum of squares: (10)2+(−15)2=100+225=325 \sqrt{(10)^2 + (-15)^2} = \sqrt{100 + 225} = \sqrt{325} .
[Practice 3 · Easy] Consider two vectors, u=[34] \mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2] \mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix} . What is the vector representing 2u−v 2\mathbf{u} - \mathbf{v} ?
💡 Hint 1 of 3
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result.
💡 Hint 2 of 3
Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix}.
💡 Hint 3 of 3
Therefore, the resulting vector is [510]\begin{bmatrix} 5 \\ 10 \end{bmatrix}.
To find the vector 2u−v 2\mathbf{u} - \mathbf{v} , we first compute 2u 2\mathbf{u} and then subtract v \mathbf{v} from the result. 2u=2×[34]=[2×32×4]=[68] 2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} . Now, we subtract v \mathbf{v} from 2u 2\mathbf{u} : 2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510] 2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix} . Therefore, the resulting vector is [510] \begin{bmatrix} 5 \\ 10 \end{bmatrix} .
[Practice 4 · Medium] Consider a dataset of n n observations (xi,yi) (x_i, y_i) for i=1,…,n i = 1, \dots, n , where xi x_i are scalar predictor variables and yi y_i are scalar response variables. The ordinary least squares (OLS) estimates for the intercept β0 \beta_0 and the slope β1 \beta_1 of the linear model y=β0+β1x+ϵ y = \beta_0 + \beta_1 x + \epsilon are given by β^1=∑i=1n(xi−xˉ)(yi−yˉ)∑i=1n(xi−xˉ)2 \hat{\beta}_1 = \frac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sum_{i=1}^n (x_i - \bar{x})^2} and β^0=yˉ−β^1xˉ \hat{\beta}_0 = \bar{y} - \hat{\beta}_1 \bar{x} . Suppose we have a dataset where n=5 n = 5 , ∑xi=15 \sum x_i = 15 , ∑yi=30 \sum y_i = 30 , ∑xi2=55 \sum x_i^2 = 55 , ∑yi2=210 \sum y_i^2 = 210 , and ∑xiyi=105 \sum x_i y_i = 105 . A new data point (x6,y6) (x_6, y_6) is added to the dataset. If the new regression line that minimizes the sum of squared errors for the n+1=6 n+1 = 6 points is parallel to the original regression line (i.e., β^1new=β^1old \hat{\beta}_1^{\text{new}} = \hat{\beta}_1^{\text{old}} ), what is the value of y6 y_6 in terms of x6 x_6 ?
💡 Hint 1 of 3
For the original n=5 n = 5 observations, xˉ=155=3 \bar{x} = \frac{15}{5} = 3 and yˉ=305\bar{y} = \frac{30}{5}.
💡 Hint 2 of 3
The sums of squares are Sxx=55−5(32)=10 S_{xx} = 55 - 5(3^2) = 10 and Sxy=105−5(3)(6)=15 S_{xy} = 105 - 5(3)(6) = 15 , giving slope β^1=1510=1.5 \hat{\beta}_1 = \frac{15}{10} = 1.5 and intercept β^0=6−1.5(3)\hat{\beta}_0 = 6 - 1.5(3).
💡 Hint 3 of 3
When a 6th point (x6,y6)(x_6, y_6) lying on the existing regression line y6=1.5x6+1.5y_6 = 1.5x_6 + 1.5 is added, the residual is zero and the OLS slope remains unchanged at 1.51.5.
For the original n=5 n = 5 observations, xˉ=155=3 \bar{x} = \frac{15}{5} = 3 and yˉ=305=6 \bar{y} = \frac{30}{5} = 6 . The sums of squares are Sxx=55−5(32)=10 S_{xx} = 55 - 5(3^2) = 10 and Sxy=105−5(3)(6)=15 S_{xy} = 105 - 5(3)(6) = 15 , giving slope β^1=1510=1.5 \hat{\beta}_1 = \frac{15}{10} = 1.5 and intercept β^0=6−1.5(3)=1.5 \hat{\beta}_0 = 6 - 1.5(3) = 1.5 . When a 6th point (x6,y6) (x_6, y_6) lying on the existing regression line y6=1.5x6+1.5 y_6 = 1.5x_6 + 1.5 is added, the residual is zero and the OLS slope remains unchanged at 1.5 1.5 .
[Practice 5 · Hard] Consider a dataset of n n data points, where each data point is a vector in RD \mathbb{R}^{D} . A non-linear dimensionality reduction technique maps these data points to a lower-dimensional space Rd \mathbb{R}^{d} . The mapping function for a single data point x∈RD \mathbf{x} \in \mathbb{R}^{D} is given by f(x)=ϕ(x) f(\mathbf{x}) = \phi(\mathbf{x}) , where ϕ:RD→Rd \phi: \mathbb{R}^{D} \to \mathbb{R}^{d} is a function designed to preserve local neighborhood structures. Suppose the mapping ϕ \phi is defined by an explicit feature map ϕ(x)=[xTx,xTx,…,xTx]T \phi(\mathbf{x}) = [\mathbf{x}^T \mathbf{x}, \mathbf{x}^T \mathbf{x}, \dots, \mathbf{x}^T \mathbf{x}]^T where the vector x∈R10 \mathbf{x} \in \mathbb{R}^{10} and d d is the dimension of the embedded space. If the goal is to embed these points into a space such that pairwise Euclidean distances are preserved as closely as possible under a specific distortion, and it is found that d=15 d=15 yields optimal results for this mapping under a certain constraint, determine the effective rank of the feature map's image space.
💡 Hint 1 of 3
The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T \phi(\mathbf{x}) = [\mathbf{x}^T \mathbf{x}, \mathbf{x}^T \mathbf{x}, \dots, \mathbf{x}^T \mathbf{x}]^T , where x∈R10 \mathbf{x} \in \mathbb{R}^{10} .
💡 Hint 2 of 3
The term xTx \mathbf{x}^T \mathbf{x} is the squared Euclidean norm of x \mathbf{x} , denoted as ∥x∥2 \|\mathbf{x}\|^2 . This is a scalar value.
💡 Hint 3 of 3
The problem states that dd, but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.
The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T \phi(\mathbf{x}) = [\mathbf{x}^T \mathbf{x}, \mathbf{x}^T \mathbf{x}, \dots, \mathbf{x}^T \mathbf{x}]^T , where x∈R10 \mathbf{x} \in \mathbb{R}^{10} . The term xTx \mathbf{x}^T \mathbf{x} is the squared Euclidean norm of x \mathbf{x} , denoted as ∥x∥2 \|\mathbf{x}\|^2 . This is a scalar value. Thus, the mapping ϕ \phi produces a vector where each component is the same scalar value, ∥x∥2 \|\mathbf{x}\|^2 . Let k=∥x∥2 k = \|\mathbf{x}\|^2 . Then ϕ(x)=[k,k,…,k]T \phi(\mathbf{x}) = [k, k, \dots, k]^T in Rd \mathbb{R}^{d} . This means that the image of the mapping ϕ \phi is a subspace spanned by a single vector. For example, if d=15 d=15 , then ϕ(x)=[k,k,…,k]T \phi(\mathbf{x}) = [k, k, \dots, k]^T which can be written as k⋅[1,1,…,1]T k \cdot [1, 1, \dots, 1]^T . The vector [1,1,…,1]T [1, 1, \dots, 1]^T forms a basis for the image space. Therefore, the dimension of the image space, which is equivalent to its rank, is 1, regardless of the value of d d (as long as d≥1 d \ge 1 ). The problem states that d=15 d=15 , but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.
📝 Chapter Quiz
5

Probability Distributions & Maximum Likelihood (MLE)

🤖 AI Math Unit 5 — Distributions & Estimation Applied STEM  ·  Gaussian / Normal distribution N(μ, σ²)  ·  Bernoulli & Binomial distributions for classification  ·  Likelihood function L(θ | data)  ·  Log-Likelihood log L(θ) and differentiation  ·  MLE parameter derivation for Gaussian mean and variance

Data in AI is modeled using probability distributions. Maximum Likelihood Estimation (MLE) is the statistical method used to find the model parameters that make the observed training data most probable.

● Definition 5.1 — Maximum Likelihood Estimation (MLE)
Given independent and identically distributed (i.i.d.) observations X={x1,x2,…,xN} X = \{x_1, x_2, \dots, x_N\} from a distribution parameterized by θ \theta :
1. Likelihood: L(θ)=∏i=1Np(xi∣θ) L(\theta) = \prod_{i=1}^N p(x_i | \theta) .
2. Log-Likelihood: ℓ(θ)=ln⁡L(θ)=∑i=1Nln⁡p(xi∣θ) \ell(\theta) = \ln L(\theta) = \sum_{i=1}^N \ln p(x_i | \theta) . Taking the logarithm converts products into sums without shifting the maximizing argument.
3. MLE Estimator: θ^MLE=arg⁡max⁡θℓ(θ) \hat{\theta}_{\text{MLE}} = \arg\max_\theta \ell(\theta) , solved by setting ∂ℓ∂θ=0 \frac{\partial \ell}{\partial \theta} = 0 .
● Deep Conceptual Intuition — Probability Distributions & Maximum Likelihood (MLE)

Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔyΔxm = \dfrac{\Delta y}{\Delta x}, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1a_1 x + b_1 y = c_1, a2x+b2y=c2a_2 x + b_2 y = c_2 has a unique intersection if a1a2≠b1b2\dfrac{a_1}{a_2} \ne \dfrac{b_1}{b_2}, no solution (parallel lines) if a1a2=b1b2≠c1c2\dfrac{a_1}{a_2} = \dfrac{b_1}{b_2} \ne \dfrac{c_1}{c_2}, and infinitely many solutions if all three ratios coincide.

Probability Distributions & Maximum Likelihood (MLE) — Linear System Intersection & Equilibrium — Coordinate plane with graph of y = 2x + 1, y = −0.5x + 6; marked points (2, 5) (2, 5)Linear System Intersection & Equilibrium-2-1123452468xy(2, 5)y = 2x + 1y = −0.5x + 6
Coordinate intersection of linear system y=2x+1y = 2x + 1 and y=−x+7y = -x + 7 at unique equilibrium point (2,5)(2, 5).
⊙ Explorer · Maximum Likelihood Estimation (MLE): Gaussian Log-Likelihood ℓ(μ)(\mu)
interactive
Log-Likelihood ℓ(μ,σ)(\mu, \sigma)ℓ=−10.36ℓ = -10.36
True Sample Mean μ^MLE=xˉ\hat{\mu }_{\text{MLE}} = \bar{x}μ^MLE=1.50\hat{\mu }_{\text{MLE}} = 1.50
Score Gradient ∂ℓ/∂μ\mu∂ℓ/∂μ=3.47∂ℓ/∂\mu = 3.47

Given 5 observed data points on the horizontal axis, slide candidate mean μ\mu to align the Gaussian bell (indigo) with the data and maximize the log-likelihood curve ℓ(μ)(\mu) (amber).

Coordinate plane with graph of y = 0.5(x-19)² + 22025303551015xy
Probability Distributions & Maximum Likelihood (MLE) — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Probability Distributions & Maximum Likelihood (MLE).
Gaussian PDF
p(x)=1σ2πe−(x−μ)22σ2 p(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}
Gaussian Mean MLE
μ^MLE=1N∑i=1Nxi \hat{\mu}_{\text{MLE}} = \frac{1}{N}\sum_{i=1}^N x_i (sample mean)
Gaussian Var MLE
σ^MLE2=1N∑i=1N(xi−μ^)2 \hat{\sigma}^2_{\text{MLE}} = \frac{1}{N}\sum_{i=1}^N (x_i - \hat{\mu})^2
Bernoulli MLE
p^MLE=kN \hat{p}_{\text{MLE}} = \frac{k}{N} (fraction of positive trials)
◆ Why It Works — First-Principles Derivation (Probability Distributions & Maximum Likelihood (MLE))

Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0Q_0 undergoes a percentage change p%p\% followed by q%q\%, the compound multiplier is the product of individual scale factors:

Qfinal=Q0(1+p100) ⁣(1+q100)=Q0(1+p+q100+pq10000) Q_{\text{final}} = Q_0\left(1 + \frac{p}{100}\right)\!\left(1 + \frac{q}{100}\right) = Q_0\left(1 + \frac{p + q}{100} + \frac{pq}{10000}\right)

Notice the cross term pq10000\dfrac{pq}{10000}: an increase of p%p\% followed by a decrease of p%p\% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).

Worked Example 5.A — Deriving the MLE of a Bernoulli Parameter

Let x1,x2,…,xN∈{0,1} x_1, x_2, \dots, x_N \in \{0, 1\} be N N binary outcomes from a coin toss with unknown bias p p . Deriving the MLE estimator for p p .

Solution:
The probability of single outcome is P(xi)=pxi(1−p)1−xi P(x_i) = p^{x_i}(1-p)^{1-x_i} .
The likelihood for N N i.i.d. observations is:
L(p)=∏i=1Npxi(1−p)1−xi=p∑xi(1−p)N−∑xi L(p) = \prod_{i=1}^N p^{x_i}(1-p)^{1-x_i} = p^{\sum x_i} (1-p)^{N - \sum x_i}
Let k=∑i=1Nxi k = \sum_{i=1}^N x_i be the total number of successes.
Log-likelihood:
ℓ(p)=ln⁡L(p)=kln⁡p+(N−k)ln⁡(1−p) \ell(p) = \ln L(p) = k \ln p + (N - k) \ln(1 - p)
Differentiate with respect to p p and set to 0:
dℓdp=kp−N−k1−p=0  ⟹  kp=N−k1−p \frac{d\ell}{dp} = \frac{k}{p} - \frac{N - k}{1 - p} = 0 \implies \frac{k}{p} = \frac{N - k}{1 - p}
k(1−p)=p(N−k)  ⟹  k−kp=Np−kp  ⟹  Np=k  ⟹  p^MLE=kN k(1 - p) = p(N - k) \implies k - kp = Np - kp \implies Np = k \implies \hat{p}_{\text{MLE}} = \frac{k}{N} .
Checking second derivative: \( \frac{d^2\ell}{dp^2} = -\frac{k}{p^2} - \frac{N-k}{(1-p)^2} < 0 \), confirming a maximum.
Answer: p^MLE=1N∑i=1Nxi \hat{p}_{\text{MLE}} = \frac{1}{N}\sum_{i=1}^N x_i .

Worked Example BB — Probability Distributions & Maximum Likelihood (MLE) (Medium Application)

Problem (Medium): Principal Component Analysis on covariance matrix ΣA \Sigma_{A} yields eigenvalues λ1=51 \lambda_1 = 51 and λ2=49 \lambda_2 = 49 . Determine the percentage of variance fx f_{x} explained by the first principal component.

Step-by-Step Solution: The percentage explained is 5151+49×100%=51% \frac{51}{51+49} \times 100\% = 51\% .

Worked Example CC — Probability Distributions & Maximum Likelihood (MLE) (Hard Application)

Problem (Hard): Consider an i.i.d. sample x1,x2,…,xn x_1, x_2, \dots, x_n from a Poisson distribution with probability mass function P(X=k;θ)=θke−θk! P(X = k; \theta) = \frac{\theta^k e^{-\theta}}{k!} for k=0,1,2,… k = 0, 1, 2, \dots , where θ>0 \theta > 0 . Given a sample of size n=5 n = 5 with sample sum ∑i=15xi=15 \sum_{i=1}^5 x_i = 15 , find the maximum likelihood estimate (MLE) θ^ \hat{\theta} of θ \theta .

Step-by-Step Solution: The log-likelihood function for n n i.i.d. Poisson(\/θ\theta) observations is: ℓ(θ)=∑i=1nxiln⁡θ−nθ−∑i=1nln⁡(xi!). \ell(\theta) = \sum_{i=1}^n x_i \ln\theta - n\theta - \sum_{i=1}^n \ln(x_i!). Setting the derivative with respect to θ \theta equal to zero gives: dℓdθ=∑i=1nxiθ−n=0  ⟹  θ^=1n∑i=1nxi=155=3. \frac{d\ell}{d\theta} = \frac{\sum_{i=1}^n x_i}{\theta} - n = 0 \implies \hat{\theta} = \frac{1}{n}\sum_{i=1}^n x_i = \frac{15}{5} = 3.

Worked Example DD — Probability Distributions & Maximum Likelihood (MLE) (Easy Application)

Problem (Easy): Consider a discrete random variable X X with the following probability mass function (PMF): P(X=x)=x10 P(X=x) = \frac{x}{10} for x∈{1,2,3,4} x \in \{1, 2, 3, 4\} . What is the value of P(X≤2) P(X \le 2) ?

Step-by-Step Solution: The probability mass function is given by P(X=x)=x10 P(X=x) = \frac{x}{10} for x∈{1,2,3,4} x \in \{1, 2, 3, 4\} . We need to find P(X≤2) P(X \le 2) . This is the sum of probabilities for X=1 X=1 and X=2 X=2 . P(X≤2)=P(X=1)+P(X=2) P(X \le 2) = P(X=1) + P(X=2) . P(X=1)=110 P(X=1) = \frac{1}{10} and P(X=2)=210 P(X=2) = \frac{2}{10} . Therefore, P(X≤2)=110+210=310 P(X \le 2) = \frac{1}{10} + \frac{2}{10} = \frac{3}{10} .

⚠️ Common Exam Traps — Probability Distributions & Maximum Likelihood (MLE)

1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20%20\% discount followed by a 20%20\% increase gives 0.80×1.20=0.960.80 \times 1.20 = 0.96 (a net 4%4\% loss, not 0%0\%). Likewise, average speed for a round trip at 4040 and 60 km/h60\text{ km/h} is 2(40)(60)100=48 km/h\dfrac{2(40)(60)}{100} = 48\text{ km/h}, never 50 km/h50\text{ km/h}.

2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −3x+3≤6-3x + 3 \le 6, dividing by −3-3 strictly reverses ≤\le to ≥\ge.

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Probability Distributions & Maximum Likelihood (MLE))
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Claiming +25%+25\% followed by −25%-25\% returns to 100%100\% The 25%25\% reduction applies to the larger base 1.25Q01.25 Q_0, not Q0Q_0. Multiply scale factors: 1.25×0.75=0.93751.25 \times 0.75 = 0.9375 (a 6.25%6.25\% net decrease).
Solving −3x>12-3x > 12 as x>−4x > -4 Dividing by a negative number reverses order on the real number line. Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).
Computing round-trip average speed as v1+v22\frac{v_1 + v_2}{2} Time spent at the slower speed is longer than time spent at the faster speed. Use total distance over total time: vavg=2v1v2v1+v2v_{\text{avg}} = \frac{2v_1 v_2}{v_1 + v_2}.
▲ Exam Pacing & Verification Strategy — Probability Distributions & Maximum Likelihood (MLE)

High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y3x + 3y rather than xx and yy individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.

[Practice 1 · Medium] A dataset consists of observations x1,x2,…,xn x_1, x_2, \dots, x_n that are assumed to be drawn independently from a Bernoulli distribution with parameter p p . The probability mass function is given by P(X=k;p)=pk(1−p)1−k P(X=k; p) = p^k (1-p)^{1-k} for k∈{0,1} k \in \{0, 1\} . The following bar chart shows the frequency distribution of these observations, where n=50 n = 50 .
{ "type": "bar", "labels": ["0", "1"], "data": [20, 30], "title": "Frequency Distribution of Bernoulli Observations" }
Using the method of Maximum Likelihood Estimation (MLE), determine the estimated value of p p for this distribution.
💡 Hint 1 of 3
The Bernoulli distribution has the probability mass function P(X=k;p)=pk(1−p)1−k P(X=k; p) = p^k (1-p)^{1-k} . The likelihood function for n n independent observations is L(p;x1,…,xn)=∏i=1npxi(1−p)1−xi L(p; x_1, \dots, x_n) = \prod_{i=1}^n p^{x_i} (1-p)^{1-x_i} . This can be rewritten as L(p)=p∑xi(1−p)n−∑xi L(p) = p^{\sum x_i} (1-p)^{n - \sum x_i} .
💡 Hint 2 of 3
Rewrite and simplify to obtain: ∑xi=np \sum x_i = np .
💡 Hint 3 of 3
Therefore, the MLE for pp is: p^MLE=3050\hat{p}_{MLE} = \frac{30}{50}.
The Bernoulli distribution has the probability mass function P(X=k;p)=pk(1−p)1−k P(X=k; p) = p^k (1-p)^{1-k} . The likelihood function for n n independent observations is L(p;x1,…,xn)=∏i=1npxi(1−p)1−xi L(p; x_1, \dots, x_n) = \prod_{i=1}^n p^{x_i} (1-p)^{1-x_i} . This can be rewritten as L(p)=p∑xi(1−p)n−∑xi L(p) = p^{\sum x_i} (1-p)^{n - \sum x_i} . The log-likelihood function is ln⁡L(p)=(∑xi)ln⁡p+(n−∑xi)ln⁡(1−p) \ln L(p) = (\sum x_i) \ln p + (n - \sum x_i) \ln(1-p) . To find the maximum likelihood estimate (MLE) of p p , we take the derivative of the log-likelihood with respect to p p and set it to zero: ddpln⁡L(p)=∑xip−n−∑xi1−p \frac{d}{dp} \ln L(p) = \frac{\sum x_i}{p} - \frac{n - \sum x_i}{1-p} Setting the derivative to zero: ∑xip=n−∑xi1−p \frac{\sum x_i}{p} = \frac{n - \sum x_i}{1-p} (∑xi)(1−p)=p(n−∑xi) (\sum x_i)(1-p) = p(n - \sum x_i) ∑xi−p∑xi=np−p∑xi \sum x_i - p \sum x_i = np - p \sum x_i ∑xi=np \sum x_i = np p^MLE=∑xin \hat{p}_{MLE} = \frac{\sum x_i}{n} This means the MLE for p p is the sample mean. From the bar chart, the frequency of observations equal to 0 is 20, and the frequency of observations equal to 1 is 30. The total number of observations is n=50 n = 50 . The sum of the observations ∑xi \sum x_i is calculated as: ∑xi=(20×0)+(30×1)=0+30=30 \sum x_i = (20 \times 0) + (30 \times 1) = 0 + 30 = 30 Therefore, the MLE for p p is: p^MLE=3050=35 \hat{p}_{MLE} = \frac{30}{50} = \frac{3}{5} Common algebraic traps: Students might incorrectly calculate the sample mean, or confuse the counts of 0s and 1s. The option 25 \frac{2}{5} would arise from incorrectly using 2050 \frac{20}{50} which represents 1−p 1-p . The option 12 \frac{1}{2} might arise from assuming equal probabilities without considering the data. The option 32 \frac{3}{2} is not a valid probability.
[Practice 2 · Hard] Consider a sequence of nn independent Bernoulli trials, where the probability of success in each trial is pp. Let XX be the random variable representing the number of successes in these nn trials. Thus, X∼Binomial(n,p)X \sim \text{Binomial}(n, p). We are given a dataset of NN observed values {x1,x2,…,xN}\{x_1, x_2, \dots, x_N\} for XX, where each xix_i is an observed count of successes from nn trials. The observed data are: [3, 4, 2, 5, 4, 3, 2, 4, 5, 3]. If we assume that n=5n=5 (the number of trials for each observation is fixed at 5), find the value of pp that maximizes the likelihood of observing this dataset. Then, compute the maximum likelihood estimate (MLE) of the probability of success, pp, and round your answer to two decimal places.
💡 Hint 1 of 3
The random variable XX follows a Binomial distribution: X∼Binomial(n,p)X \sim \text{Binomial}(n, p). The probability mass function (PMF) of the Binomial distribution is given by P(X=k∣n,p)=(nk)pk(1−p)n−kP(X=k | n, p) = \binom{n}{k} p^k (1-p)^{n-k}, where kk is the number of successes.
💡 Hint 2 of 3
Rewrite and simplify to obtain: Sp=T1−p\frac{S}{p} = \frac{T}{1-p}.
💡 Hint 3 of 3
Let's check the second derivative to confirm it's a maximum: d2ℓdp2=−Sp2−T(1−p)2\frac{d^2\ell}{dp^2} = -\frac{S}{p^2} - \frac{T}{(1-p)^2}. Since S>0S>0, T>0T>0, p∈(0,1)p \in (0,1), the second derivative is negative, confirming a maximum.
The random variable XX follows a Binomial distribution: X∼Binomial(n,p)X \sim \text{Binomial}(n, p). The probability mass function (PMF) of the Binomial distribution is given by P(X=k∣n,p)=(nk)pk(1−p)n−kP(X=k | n, p) = \binom{n}{k} p^k (1-p)^{n-k}, where kk is the number of successes. We are given n=5n=5 and a dataset of N=10N=10 observations: {x1,x2,…,x10}={3,4,2,5,4,3,2,4,5,3}\{x_1, x_2, \dots, x_{10}\} = \{3, 4, 2, 5, 4, 3, 2, 4, 5, 3\}. The likelihood function for this dataset, given pp, is the product of the PMFs for each observation: L(p∣{xi})=∏i=1NP(X=xi∣n,p)=∏i=110(5xi)pxi(1−p)5−xiL(p | \{x_i\}) = \prod_{i=1}^{N} P(X=x_i | n, p) = \prod_{i=1}^{10} \binom{5}{x_i} p^{x_i} (1-p)^{5-x_i} To find the MLE of pp, we typically work with the log-likelihood function, which simplifies the product into a sum: ℓ(p)=log⁡L(p)=∑i=110log⁡((5xi)pxi(1−p)5−xi)\ell(p) = \log L(p) = \sum_{i=1}^{10} \log \left( \binom{5}{x_i} p^{x_i} (1-p)^{5-x_i} \right) ℓ(p)=∑i=110(log⁡(5xi)+xilog⁡p+(5−xi)log⁡(1−p))\ell(p) = \sum_{i=1}^{10} \left( \log \binom{5}{x_i} + x_i \log p + (5-x_i) \log (1-p) \right) ℓ(p)=∑i=110log⁡(5xi)+(∑i=110xi)log⁡p+(∑i=110(5−xi))log⁡(1−p)\ell(p) = \sum_{i=1}^{10} \log \binom{5}{x_i} + \left(\sum_{i=1}^{10} x_i\right) \log p + \left(\sum_{i=1}^{10} (5-x_i)\right) \log (1-p) The term ∑i=110log⁡(5xi)\sum_{i=1}^{10} \log \binom{5}{x_i} is a constant with respect to pp and can be ignored for maximization. Let S=∑i=110xiS = \sum_{i=1}^{10} x_i be the total number of successes in the dataset, and T=∑i=110(5−xi)=10×5−∑i=110xi=50−ST = \sum_{i=1}^{10} (5-x_i) = 10 \times 5 - \sum_{i=1}^{10} x_i = 50 - S be the total number of failures. So, ℓ(p)≈Slog⁡p+Tlog⁡(1−p)\ell(p) \approx S \log p + T \log (1-p). To find the MLE, we take the derivative of ℓ(p)\ell(p) with respect to pp and set it to zero: dℓdp=Sp−T1−p=0\frac{d\ell}{dp} = \frac{S}{p} - \frac{T}{1-p} = 0 Sp=T1−p\frac{S}{p} = \frac{T}{1-p} S(1−p)=TpS(1-p) = Tp S−Sp=TpS - Sp = Tp S=Tp+SpS = Tp + Sp S=p(T+S)S = p(T+S) p=ST+Sp = \frac{S}{T+S} We know that T+S=∑i=110(5−xi)+∑i=110xi=∑i=110(5−xi+xi)=∑i=1105=10×5=50T+S = \sum_{i=1}^{10} (5-x_i) + \sum_{i=1}^{10} x_i = \sum_{i=1}^{10} (5-x_i+x_i) = \sum_{i=1}^{10} 5 = 10 \times 5 = 50. Now, let's calculate SS, the sum of the observed successes: S=3+4+2+5+4+3+2+4+5+3=35S = 3 + 4 + 2 + 5 + 4 + 3 + 2 + 4 + 5 + 3 = 35. Therefore, the MLE of pp is: p^=SnN=355×10=3550=710=0.70\hat{p} = \frac{S}{nN} = \frac{35}{5 \times 10} = \frac{35}{50} = \frac{7}{10} = 0.70. The maximum likelihood estimate of pp is 0.70. Let's check the second derivative to confirm it's a maximum: d2ℓdp2=−Sp2−T(1−p)2\frac{d^2\ell}{dp^2} = -\frac{S}{p^2} - \frac{T}{(1-p)^2}. Since S>0S>0, T>0T>0, p∈(0,1)p \in (0,1), the second derivative is negative, confirming a maximum. Common Misconception: A common mistake might be to incorrectly calculate the sum of successes or failures, or to use the wrong formula for the MLE of a binomial proportion, such as simply averaging the proportions of successes in each trial (which is not applicable here as nn is fixed). For example, if one made an arithmetic error and got S=30S=30, then p^=30/50=0.60\hat{p} = 30/50 = 0.60. If S=37.5S=37.5 (an impossible sum, but for illustration of error), p^=37.5/50=0.75\hat{p}=37.5/50 = 0.75. If S=30S=30, p^=30/50=0.6\hat{p}=30/50=0.6. If S=33.5S=33.5, p^=33.5/50=0.67\hat{p}=33.5/50=0.67.
[Practice 3 · Easy] Consider a dataset where the number of defective items produced by a machine per hour, Y Y , follows a Poisson distribution with a rate parameter λ=3 \lambda = 3 . The probability mass function (PMF) for a Poisson distribution is given by P(Y=k)=λke−λk! P(Y=k) = \frac{\lambda^k e^{-\lambda}}{k!} for k=0,1,2,… k = 0, 1, 2, \dots . What is the value of λ \lambda in this scenario?
💡 Hint 1 of 3
The problem statement explicitly defines that the number of defective items, Y Y , follows a Poisson distribution with a rate parameter λ=3 \lambda = 3 .
💡 Hint 2 of 3
The rate parameter λ \lambda is a direct characteristic of the Poisson distribution that determines its mean and variance.
💡 Hint 3 of 3
Therefore, the value of λ\lambda is directly given as 3.
The problem statement explicitly defines that the number of defective items, Y Y , follows a Poisson distribution with a rate parameter λ=3 \lambda = 3 . The rate parameter λ \lambda is a direct characteristic of the Poisson distribution that determines its mean and variance. Therefore, the value of λ \lambda is directly given as 3.
[Practice 4 · Easy] A feature in an AI vision model follows a normal distribution X∼N(25,36) X \sim \mathcal{N}(25, 36) . What is the mean μ \mu and variance σ2 \sigma^2 of this feature?
💡 Hint 1 of 3
Start by examining the given mathematical expression in the problem: X∼N(25,36)X \sim \mathcal{N}(25, 36).
💡 Hint 2 of 3
The notation N(μ,σ2)\mathcal{N}(\mu, \sigma^2) directly specifies the mean μ=25\mu = 25 and variance σ2=36\sigma^2 = 36 (with standard deviation σ\sigma).
💡 Hint 3 of 3
Apply this step to σ\sigma and simplify to determine the final result.
The notation N(μ,σ2) \mathcal{N}(\mu, \sigma^2) directly specifies the mean μ=25 \mu = 25 and variance σ2=36 \sigma^2 = 36 (with standard deviation σ=6 \sigma = 6 ).
[Practice 5 · Medium] A dataset consists of three independent observations X1,X2,X3 X_1, X_2, X_3 drawn from a Poisson distribution with parameter λ \lambda . The observed values are x1=3,x2=5,x3=4 x_1 = 3, x_2 = 5, x_3 = 4 . We want to find the Maximum Likelihood Estimate (MLE) for λ \lambda . The log-likelihood function for a Poisson distribution is given by ℓ(λ)=∑i=1n(xilog⁡(λ)−log⁡(xi!)−λ) \ell(\lambda) = \sum_{i=1}^{n} \left( x_i \log(\lambda) - \log(x_i!) - \lambda \right) . Part 1: Derive the expression for the derivative of the log-likelihood function with respect to λ \lambda . Part 2: Set the derivative to zero to find the MLE of λ \lambda .
💡 Hint 1 of 3
The log-likelihood function for n=3 n=3 observations is ℓ(λ)=(x1log⁡(λ)−log⁡(x1!)−λ)+(x2log⁡(λ)−log⁡(x2!)−λ)+(x3log⁡(λ)−log⁡(x3!)−λ) \ell(\lambda) = (x_1 \log(\lambda) - \log(x_1!) - \lambda) + (x_2 \log(\lambda) - \log(x_2!) - \lambda) + (x_3 \log(\lambda) - \log(x_3!) - \lambda) .
💡 Hint 2 of 3
Rewrite and simplify to obtain: x1+x2+x3λ−3=0 \frac{x_1 + x_2 + x_3}{\lambda} - 3 = 0 .
💡 Hint 3 of 3
Substituting the observed values x1=3,x2=5,x3x_1 = 3, x_2 = 5, x_3: λ^=3+5+43\hat{\lambda} = \frac{3+5+4}{3}.
The log-likelihood function for n=3 n=3 observations is ℓ(λ)=(x1log⁡(λ)−log⁡(x1!)−λ)+(x2log⁡(λ)−log⁡(x2!)−λ)+(x3log⁡(λ)−log⁡(x3!)−λ) \ell(\lambda) = (x_1 \log(\lambda) - \log(x_1!) - \lambda) + (x_2 \log(\lambda) - \log(x_2!) - \lambda) + (x_3 \log(\lambda) - \log(x_3!) - \lambda) . Part 1: The derivative of the log-likelihood function with respect to λ \lambda is: dℓdλ=∑i=13(xiλ−1)=(x1λ−1)+(x2λ−1)+(x3λ−1) \frac{d\ell}{d\lambda} = \sum_{i=1}^{3} \left( \frac{x_i}{\lambda} - 1 \right) = \left( \frac{x_1}{\lambda} - 1 \right) + \left( \frac{x_2}{\lambda} - 1 \right) + \left( \frac{x_3}{\lambda} - 1 \right) . Part 2: To find the MLE, we set the derivative to zero: x1λ−1+x2λ−1+x3λ−1=0 \frac{x_1}{\lambda} - 1 + \frac{x_2}{\lambda} - 1 + \frac{x_3}{\lambda} - 1 = 0 x1+x2+x3λ−3=0 \frac{x_1 + x_2 + x_3}{\lambda} - 3 = 0 x1+x2+x3λ=3 \frac{x_1 + x_2 + x_3}{\lambda} = 3 λ^=x1+x2+x33 \hat{\lambda} = \frac{x_1 + x_2 + x_3}{3} . Substituting the observed values x1=3,x2=5,x3=4 x_1 = 3, x_2 = 5, x_3 = 4 : λ^=3+5+43=123=4 \hat{\lambda} = \frac{3+5+4}{3} = \frac{12}{3} = 4 . Common algebraic traps include incorrectly differentiating the log-likelihood or making errors in solving for λ \lambda . For example, forgetting the −1 -1 term from the derivative of −λ -\lambda leads to an incorrect denominator. Choice B is incorrect as it includes e e which is not part of the Poisson MLE derivation. Choice C is an incomplete and incorrect expression. Choice D is only correct if the sum of observations was 12, but the formula for λ^ \hat{\lambda} is the sample mean. Therefore, the MLE is λ^=4 \hat{\lambda} = 4 .
📝 Chapter Quiz
6

Linear Regression & Ordinary Least Squares

🤖 AI Math Unit 6 — Linear Models & OLS Applied STEM  ·  Simple linear regression: y = mx + b  ·  Matrix formulation Y = Xw + ε  ·  Ordinary Least Squares (OLS) closed form  ·  Normal equation w = (XᵀX)⁻¹ Xᵀ y  ·  Residuals, MSE and R² coefficient of determination

Linear regression is the foundational predictive model in data science. We explore both algebraic least-squares minimization and the closed-form matrix Normal Equation used across analytics libraries.

▲ Theorem 6.1 — The Matrix Normal Equation
For a linear model y=Xw \mathbf{y} = \mathbf{X}\mathbf{w} where X∈RN×(d+1) \mathbf{X} \in \mathbb{R}^{N \times (d+1)} is the design matrix (including a column of ones for intercept), the weight vector w \mathbf{w} that minimizes the sum of squared errors ∥y−Xw∥2 \|\mathbf{y} - \mathbf{X}\mathbf{w}\|^2 satisfies:
XTXw=XTy  ⟹  w=(XTX)−1XTy \mathbf{X}^T \mathbf{X} \mathbf{w} = \mathbf{X}^T \mathbf{y} \implies \mathbf{w} = (\mathbf{X}^T \mathbf{X})^{-1} \mathbf{X}^T \mathbf{y}
provided XTX \mathbf{X}^T \mathbf{X} is invertible (non-singular).
● Deep Conceptual Intuition — Linear Regression & Ordinary Least Squares

Proportional Invariance, Linear Structure & Quantitative Modeling: Across Mathematics for Artificial Intelligence & Machine Learning, multi-step problems reduce to identifying invariant quantities—constant rates of change m=ΔyΔxm = \dfrac{\Delta y}{\Delta x}, conservation of total work/mass, or linear system rank conditions. A two-variable linear system a1x+b1y=c1a_1 x + b_1 y = c_1, a2x+b2y=c2a_2 x + b_2 y = c_2 has a unique intersection if a1a2≠b1b2\dfrac{a_1}{a_2} \ne \dfrac{b_1}{b_2}, no solution (parallel lines) if a1a2=b1b2≠c1c2\dfrac{a_1}{a_2} = \dfrac{b_1}{b_2} \ne \dfrac{c_1}{c_2}, and infinitely many solutions if all three ratios coincide.

Linear Regression & Ordinary Least Squares — Linear System Intersection & Equilibrium — Coordinate plane with graph of y = 2.5x − 1, y = −0.5x + 5; marked points (2, 4) (2, 4)Linear System Intersection & Equilibrium-112345-22468xy(2, 4)y = 2.5x − 1y = −0.5x + 5
Coordinate intersection of linear system y=2x+1y = 2x + 1 and y=−x+7y = -x + 7 at unique equilibrium point (2,5)(2, 5).
⊙ Explorer · Ordinary Least Squares (OLS) Regression Line & Residual MSE
interactive
Mean Squared Error MSE(w,b)(w, b)MSE = 0.124
Optimal Normal-Eq (w∗,b∗)(w*, b*)w∗=1.04,b∗=0.50w* = 1.04, b* = 0.50
Coefficient of Determination R2R^{2}R2=0.943R^{2} = 0.943

Vertical amber segments show the residuals ei=yi−(w⋅xi+b)e_i = y_i -(w \cdot x_i + b) for each training point. Minimizing Σ\Sigma e_i2i^{2} yields the dashed ordinary least squares line.

Scatter plot: Regression Line and Observations; x: Feature x; y: Target yRegression Line and Observations123345212835435057Feature xTarget y(1, 25)(2, 32)(3, 39)(5, 53)
Regression Line and Observations — illustrating key geometric and analytical relationships in Linear Regression & Ordinary Least Squares.
Slope Formula
m=∑(xi−xˉ)(yi−yˉ)∑(xi−xˉ)2=SxySxx m = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^2} = \frac{S_{xy}}{S_{xx}}
Intercept
b=yˉ−mxˉ b = \bar{y} - m\bar{x}
R² Score
R2=1−SSresSStot∈[0,1] R^2 = 1 - \frac{\text{SS}_{\text{res}}}{\text{SS}_{\text{tot}}} \in [0, 1]
Residual Vector
e=y−y^⊥col(X) \mathbf{e} = \mathbf{y} - \hat{\mathbf{y}} \perp \text{col}(\mathbf{X})
◆ Why It Works — First-Principles Derivation (Linear Regression & Ordinary Least Squares)

Why Successive Multipliers & Harmonic Average Speed Work: If a quantity Q0Q_0 undergoes a percentage change p%p\% followed by q%q\%, the compound multiplier is the product of individual scale factors:

Qfinal=Q0(1+p100) ⁣(1+q100)=Q0(1+p+q100+pq10000) Q_{\text{final}} = Q_0\left(1 + \frac{p}{100}\right)\!\left(1 + \frac{q}{100}\right) = Q_0\left(1 + \frac{p + q}{100} + \frac{pq}{10000}\right)

Notice the cross term pq10000\dfrac{pq}{10000}: an increase of p%p\% followed by a decrease of p%p\% yields \(Q_0\bigl(1 - (p/100)^2\bigr) < Q_0\). Similarly, traveling equal distance \(d\) at speeds \(v_1\) and \(v_2\) takes total time \(T = \frac{d}{v_1} + \frac{d}{v_2}\), so average speed is the harmonic mean \(v_{\text{avg}} = \dfrac{2d}{d/v_1 + d/v_2} = \dfrac{2v_1 v_2}{v_1 + v_2}\).

Worked Example 6.A — Closed-Form Matrix Normal Equation

Fit a line y=w1x+w0 y = w_1 x + w_0 to three points: (1,2) (1, 2) , (2,3) (2, 3) , and (3,5) (3, 5) using the Normal Equation.

Solution:
1. Set up design matrix X \mathbf{X} (with bias column) and target y \mathbf{y} :
X=(112131),y=(235) \mathbf{X} = \begin{pmatrix} 1 & 1 \\ 2 & 1 \\ 3 & 1 \end{pmatrix}, \quad \mathbf{y} = \begin{pmatrix} 2 \\ 3 \\ 5 \end{pmatrix}
2. Compute XTX \mathbf{X}^T \mathbf{X} :
XTX=(123111)(112131)=(1+4+91+2+31+2+31+1+1)=(14663) \mathbf{X}^T \mathbf{X} = \begin{pmatrix} 1 & 2 & 3 \\ 1 & 1 & 1 \end{pmatrix} \begin{pmatrix} 1 & 1 \\ 2 & 1 \\ 3 & 1 \end{pmatrix} = \begin{pmatrix} 1+4+9 & 1+2+3 \\ 1+2+3 & 1+1+1 \end{pmatrix} = \begin{pmatrix} 14 & 6 \\ 6 & 3 \end{pmatrix}
3. Invert XTX \mathbf{X}^T \mathbf{X} :
det⁡=(14)(3)−(6)(6)=42−36=6 \det = (14)(3) - (6)(6) = 42 - 36 = 6 .
(XTX)−1=16(3−6−614) (\mathbf{X}^T \mathbf{X})^{-1} = \frac{1}{6} \begin{pmatrix} 3 & -6 \\ -6 & 14 \end{pmatrix}
4. Compute XTy \mathbf{X}^T \mathbf{y} :
XTy=(123111)(235)=(2+6+152+3+5)=(2310) \mathbf{X}^T \mathbf{y} = \begin{pmatrix} 1 & 2 & 3 \\ 1 & 1 & 1 \end{pmatrix} \begin{pmatrix} 2 \\ 3 \\ 5 \end{pmatrix} = \begin{pmatrix} 2 + 6 + 15 \\ 2 + 3 + 5 \end{pmatrix} = \begin{pmatrix} 23 \\ 10 \end{pmatrix}
5. Compute w=(XTX)−1(XTy) \mathbf{w} = (\mathbf{X}^T \mathbf{X})^{-1} (\mathbf{X}^T \mathbf{y}) :
w=16(3(23)−6(10)−6(23)+14(10))=16(69−60−138+140)=16(92)=(1.50.333) \mathbf{w} = \frac{1}{6} \begin{pmatrix} 3(23) - 6(10) \\ -6(23) + 14(10) \end{pmatrix} = \frac{1}{6} \begin{pmatrix} 69 - 60 \\ -138 + 140 \end{pmatrix} = \frac{1}{6} \begin{pmatrix} 9 \\ 2 \end{pmatrix} = \begin{pmatrix} 1.5 \\ 0.333 \end{pmatrix}
Line equation: y^=1.5x+13 \hat{y} = 1.5x + \frac{1}{3} .
Answer: Slope w1=1.5 w_1 = 1.5 , Intercept w0=13 w_0 = \frac{1}{3} .

Worked Example BB — Linear Regression & Ordinary Least Squares (Hard Application)

Problem (Hard): A simple linear regression model has been fitted to a dataset. The model equation is given by y^=ax+b \hat{y} = ax + b . The regression line passes through the points (2,10) (2, 10) and (5,22) (5, 22) in the feature-target space. Determine the value of the intercept b b .

Step-by-Step Solution: The problem states that the linear regression line y^=ax+b \hat{y} = ax + b passes through two points: (x1,y1)=(2,10) (x_1, y_1) = (2, 10) and (x2,y2)=(5,22) (x_2, y_2) = (5, 22) . We can use these two points to form a system of linear equations to solve for the unknown parameters a a (the slope) and b b (the intercept). Substituting the first point (2,10) (2, 10) into the equation y^=ax+b \hat{y} = ax + b gives: 10=a(2)+b 10 = a(2) + b (Equation 1) Substituting the second point (5,22) (5, 22) into the equation y^=ax+b \hat{y} = ax + b gives: 22=a(5)+b 22 = a(5) + b (Equation 2) To find the slope a a , we can subtract Equation 1 from Equation 2: (22−10)=(5a−2a)+(b−b) (22 - 10) = (5a - 2a) + (b - b) 12=3a 12 = 3a a=123=4 a = \frac{12}{3} = 4 Now that we have the value of a a , we can substitute it back into either Equation 1 or Equation 2 to solve for b b . Let's use Equation 1: 10=4(2)+b 10 = 4(2) + b 10=8+b 10 = 8 + b b=10−8 b = 10 - 8 b=2 b = 2 Let's verify with Equation 2: 22=4(5)+b 22 = 4(5) + b 22=20+b 22 = 20 + b b=22−20 b = 22 - 20 b=2 b = 2 Both equations yield b=2 b = 2 . Therefore, the intercept b b is 2. Common algebraic traps include incorrectly calculating the slope or making sign errors when substituting values back into the equations. For instance, if one incorrectly calculated the slope as 312 \frac{3}{12} or made a sign error in 10−8 10 - 8 , they might arrive at an incorrect intercept.

Worked Example CC — Linear Regression & Ordinary Least Squares (Easy Application)

Problem (Easy): In gradient descent on loss f(x) f(x) , parameter x0=30 x_0 = 30 is updated with learning rate η=0.1 \eta = 0.1 and gradient ∇f(x0)=20 \nabla f(x_0) = 20 . Determine the updated parameter x1=x0−η∇f(x0) x_1 = x_0 - \eta \nabla f(x_0) .

Step-by-Step Solution: Computing x1=30−0.1(20)=28 x_1 = 30 - 0.1(20) = 28 .

Worked Example DD — Linear Regression & Ordinary Least Squares (Medium Application)

Problem (Medium): Consider a simple linear regression model where the predicted value y^ \hat{y} is related to the independent variable x x by the equation y^=mx+c \hat{y} = mx + c . If the line of best fit passes through the points (1,5) (1, 5) and (3,11) (3, 11) , what is the slope m m of this line?

Step-by-Step Solution: The slope m m of a line passing through two points (x1,y1) (x_1, y_1) and (x2,y2) (x_2, y_2) is given by the formula m=y2−y1x2−x1 m = \frac{y_2 - y_1}{x_2 - x_1} . Given the points (1,5) (1, 5) and (3,11) (3, 11) , we have x1=1 x_1 = 1 , y1=5 y_1 = 5 , x2=3 x_2 = 3 , and y2=11 y_2 = 11 . Plugging these values into the formula, we get m=11−53−1=62=3 m = \frac{11 - 5}{3 - 1} = \frac{6}{2} = 3 . Therefore, the slope of the line of best fit is 3.

⚠️ Common Exam Traps — Linear Regression & Ordinary Least Squares

1. Adding Successive Percentages or Averaging Speeds Arithmetically: On Mathematics for Artificial Intelligence & Machine Learning, a 20%20\% discount followed by a 20%20\% increase gives 0.80×1.20=0.960.80 \times 1.20 = 0.96 (a net 4%4\% loss, not 0%0\%). Likewise, average speed for a round trip at 4040 and 60 km/h60\text{ km/h} is 2(40)(60)100=48 km/h\dfrac{2(40)(60)}{100} = 48\text{ km/h}, never 50 km/h50\text{ km/h}.

2. Failing to Flip the Inequality Sign When Multiplying/Dividing by a Negative: In −2x+5≤7-2x + 5 \le 7, dividing by −2-2 strictly reverses ≤\le to ≥\ge.

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Linear Regression & Ordinary Least Squares)
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Claiming +25%+25\% followed by −25%-25\% returns to 100%100\% The 25%25\% reduction applies to the larger base 1.25Q01.25 Q_0, not Q0Q_0. Multiply scale factors: 1.25×0.75=0.93751.25 \times 0.75 = 0.9375 (a 6.25%6.25\% net decrease).
Solving −3x>12-3x > 12 as x>−4x > -4 Dividing by a negative number reverses order on the real number line. Flip the inequality symbol whenever multiplying or dividing by a negative: \(x < -4\).
Computing round-trip average speed as v1+v22\frac{v_1 + v_2}{2} Time spent at the slower speed is longer than time spent at the faster speed. Use total distance over total time: vavg=2v1v2v1+v2v_{\text{avg}} = \frac{2v_1 v_2}{v_1 + v_2}.
▲ Exam Pacing & Verification Strategy — Linear Regression & Ordinary Least Squares

High-Speed Exam Shortcut (Mathematics for Artificial Intelligence & Machine Learning): When a linear system asks for a combined expression like 3x+3y3x + 3y rather than xx and yy individually, add or subtract the two equations directly before isolating either variable—this often yields the target expression in a single step.

[Practice 1 · Hard] A 2D loss surface is defined as L(w1,w2)=4w12+7w22 L(w_1, w_2) = 4w_1^2 + 7w_2^2 . Find the gradient vector ∇L \nabla L at the point (w1,w2)=(2,−1) (w_1, w_2) = (2, -1) .
💡 Hint 1 of 3
Compute partial derivatives: ∂L∂w1=2(4)w1=8(2)\frac{\partial L}{\partial w_1} = 2(4)w_1 = 8(2).
💡 Hint 2 of 3
Rewrite and simplify to obtain: ∂L∂w2=2(7)w2=14(−1)\frac{\partial L}{\partial w_2} = 2(7)w_2 = 14(-1).
💡 Hint 3 of 3
Therefore, ∇L=[16,−14]T\nabla L = [16, -14]^T.
Compute partial derivatives: ∂L∂w1=2(4)w1=8(2)=16 \frac{\partial L}{\partial w_1} = 2(4)w_1 = 8(2) = 16 ; ∂L∂w2=2(7)w2=14(−1)=−14 \frac{\partial L}{\partial w_2} = 2(7)w_2 = 14(-1) = -14 . Therefore, ∇L=[16,−14]T \nabla L = [16, -14]^T .
[Practice 2 · Easy] A fully-connected dense layer maps an input x∈R50 \mathbf{x} \in \mathbb{R}^{50} to y∈R25 \mathbf{y} \in \mathbb{R}^{25} using y=Wx+b \mathbf{y} = \mathbf{W}\mathbf{x} + \mathbf{b} . How many total learnable parameters are in this layer?
💡 Hint 1 of 3
The weight matrix W \mathbf{W} has shape 25×50 25 \times 50 , giving 1250 1250 weights.
💡 Hint 2 of 3
The bias vector b \mathbf{b} has 25 25 parameters.
💡 Hint 3 of 3
Substitute the result from the previous step into the governing relation and verify the problem condition to find the final answer.
The weight matrix W \mathbf{W} has shape 25×50 25 \times 50 , giving 1250 1250 weights. The bias vector b \mathbf{b} has 25 25 parameters. Total = 1250+25=1275 1250 + 25 = 1275 .
[Practice 3 · Easy] In a dataset, the prior probability of class C1 C_1 is P(C1)=0.10 P(C_1) = 0.10 . What is the probability of the complement class P(¬C1) P(\neg C_1) ?
💡 Hint 1 of 3
By the complement rule of probability: P(egC1)=1−P(C1)P( eg C_1) = 1 - P(C_1).
💡 Hint 2 of 3
Substitute and simplify: P(egC1)=1−0.10P( eg C_1) = 1 - 0.10.
💡 Hint 3 of 3
Compute the final value from: 1−0.101 - 0.10.
By the complement rule of probability: P(egC1)=1−P(C1)=1−0.10=0.90 P( eg C_1) = 1 - P(C_1) = 1 - 0.10 = 0.90 .
[Practice 4 · Medium] Consider a simple linear regression model where a dependent variable y y is predicted from an independent variable x x . The model is given by the equation y=β0+β1x+ϵ y = \beta_0 + \beta_1 x + \epsilon , where ϵ \epsilon is the error term. Suppose we have estimated the regression line to be y^=3+2x \hat{y} = 3 + 2x . If we observe an independent variable value of x=4 x=4 , what is the predicted value y^ \hat{y} for the dependent variable?
💡 Hint 1 of 3
The problem asks for the predicted value y^ \hat{y} given an independent variable value x=4 x=4 and a linear regression equation y^=3+2x \hat{y} = 3 + 2x . We substitute the value of x x into the equation: y^=3+2(4) \hat{y} = 3 + 2(4) .
💡 Hint 2 of 3
Rewrite and simplify to obtain: y^=3+8 \hat{y} = 3 + 8 y^=11 \hat{y} = 11 .
💡 Hint 3 of 3
Therefore, the predicted value for the dependent variable is 11.
The problem asks for the predicted value y^ \hat{y} given an independent variable value x=4 x=4 and a linear regression equation y^=3+2x \hat{y} = 3 + 2x . We substitute the value of x x into the equation: y^=3+2(4) \hat{y} = 3 + 2(4) y^=3+8 \hat{y} = 3 + 8 y^=11 \hat{y} = 11 Therefore, the predicted value for the dependent variable is 11. Common errors might involve incorrectly multiplying 2 by 4 or incorrectly adding 3 to 8.
[Practice 5 · Hard] In anomaly detection, anomaly prior P(A)=0.10 P(A) = 0.10 , detection sensitivity P(+∣A)=0.95 P(+|A) = 0.95 , and false alarm rate P(+∣¬A)=0.05 P(+|\neg A) = 0.05 . By Bayes' theorem, what is the posterior probability P(A∣+) P(A|+) that an alarm is a true anomaly?
💡 Hint 1 of 3
By Bayes' Rule: P(A∣+)=P(+∣A)P(A)P(+∣A)P(A)+P(+∣egA)P(egA)P(A|+) = \frac{P(+|A)P(A)}{P(+|A)P(A) + P(+| eg A)P( eg A)}.
💡 Hint 2 of 3
Substitute and simplify: P(A∣+)=0.95×0.100.95(0.10)+0.05(0.90)P(A|+) = \frac{0.95 \times 0.10}{0.95(0.10) + 0.05(0.90)}.
💡 Hint 3 of 3
Compute the final value from: 0.09500.1400\frac{0.0950}{0.1400}.
By Bayes' Rule: P(A∣+)=P(+∣A)P(A)P(+∣A)P(A)+P(+∣egA)P(egA)=0.95×0.100.95(0.10)+0.05(0.90)=0.09500.1400=0.679 P(A|+) = \frac{P(+|A)P(A)}{P(+|A)P(A) + P(+| eg A)P( eg A)} = \frac{0.95 \times 0.10}{0.95(0.10) + 0.05(0.90)} = \frac{0.0950}{0.1400} = 0.679 .
📝 Chapter Quiz
7

Logistic Regression & Classification Boundaries

🤖 AI Math Unit 7 — Logistic Classification Applied STEM  ·  Binary classification & probabilities  ·  The Sigmoid function σ(z) = 1 / (1 + e⁻ᶻ)  ·  Log-odds (Logit) transformation  ·  Binary Cross-Entropy (Log Loss) function  ·  Linear decision boundaries and threshold tuning

When the target variable is categorical (0 or 1, positive or negative), standard linear regression fails. Logistic regression maps continuous linear combinations to calibrated probabilities using the Sigmoid curve.

● Definition 7.1 — Sigmoid & Binary Cross-Entropy
1. Sigmoid Function: σ(z)=11+e−z \sigma(z) = \frac{1}{1 + e^{-z}} .
Key properties: σ(0)=0.5 \sigma(0) = 0.5 , lim⁡z→∞σ(z)=1 \lim_{z \to \infty} \sigma(z) = 1 , lim⁡z→−∞σ(z)=0 \lim_{z \to -\infty} \sigma(z) = 0 . Derivative: σ′(z)=σ(z)(1−σ(z)) \sigma'(z) = \sigma(z)(1 - \sigma(z)) .

2. Binary Cross-Entropy Loss: For true label y∈{0,1} y \in \{0, 1\} and model prediction y^=σ(wTx) \hat{y} = \sigma(\mathbf{w}^T\mathbf{x}) :
L(y,y^)=−[yln⁡y^+(1−y)ln⁡(1−y^)] L(y, \hat{y}) = -\Big[ y \ln\hat{y} + (1 - y) \ln(1 - \hat{y}) \Big]
● Deep Conceptual Intuition — Logistic Regression & Classification Boundaries

Accumulation, Antiderivatives & Differential Flows: By the Fundamental Theorem of Calculus, the accumulation function A(x)=∫axf(t) dtA(x) = \int_a^x f(t)\,dt satisfies A′(x)=f(x)A'(x) = f(x), linking instantaneous rates of change to net signed area. In first-order differential equations dydx=g(x)h(y)\dfrac{dy}{dx} = g(x)h(y), separation of variables ∫1h(y) dy=∫g(x) dx+C\int \dfrac{1}{h(y)}\,dy = \int g(x)\,dx + C reconstructs the family of integral curves across the slope field.

Slope field for differential equation dy/dx = 0.25(x + y): Logistic Regression & Classification Boundaries — Slope Field & Particular Solution TrajectorySlope Field & Particular Solution Trajectory
Slope field for dydx=x−y\frac{dy}{dx} = x -y with the integral curve passing through initial condition (0,1)(0, 1).
⊙ Explorer · Logistic Regression Sigmoid σ\sigma(wx + bb) & Decision Boundary
interactive
Decision Boundary x* = −b/w-b / wx∗=0.50x* = 0.50
Probability σ(w⋅1+b)\sigma (w \cdot 1 + b)σ(z)=0.711\sigma (z) = 0.711
Binary Cross-Entropy LossBCE ≈ 0.389

Class 0 (indigo dots at y=0y = 0) and Class 1 (amber dots at y=1y = 1) are separated by the sigmoid curve P(y=1∣x)=1P(y=1|x) = 1/(1 + e^(−(wx+bb))), which crosses 0.5 at x* = −b/w-b / w.

Binary Classification Contingency Table
Pred PositivePred Negative
Actual Positive4510
Actual Negative1040
Binary Classification Contingency Table — illustrating key geometric and analytical relationships in Logistic Regression & Classification Boundaries.
Odds Ratio
Odds=p1−p=ewTx \text{Odds} = \frac{p}{1-p} = e^{\mathbf{w}^T\mathbf{x}}
Log-Odds (Logit)
ln⁡(p1−p)=wTx \ln\left(\frac{p}{1-p}\right) = \mathbf{w}^T\mathbf{x}
Decision Boundary
y^≥0.5  ⟺  wTx≥0 \hat{y} \ge 0.5 \iff \mathbf{w}^T\mathbf{x} \ge 0 (hyperplane separating classes)
Loss Derivative
∂L∂w=(y^−y)x \frac{\partial L}{\partial \mathbf{w}} = (\hat{y} - y)\mathbf{x} (remarkably clean!)
◆ Why It Works — First-Principles Derivation (Logistic Regression & Classification Boundaries)

Why Integration by Parts & Integrating Factors Work: Differentiating a product u(x)v(x)u(x)v(x) gives (uv)′=u′v+uv′(uv)' = u'v + uv'. Integrating both sides and rearranging yields the Integration by Parts formula:

∫u dvdx dx=uv−∫v dudx dx \int u\,\frac{dv}{dx}\,dx = u v - \int v\,\frac{du}{dx}\,dx

Similarly, for a linear first-order ODE y′+P(x)y=Q(x)y' + P(x)y = Q(x), multiplying by the integrating factor μ(x)=e∫P(x) dx\mu(x) = e^{\int P(x)\,dx} (which satisfies μ′(x)=P(x)μ(x)\mu'(x) = P(x)\mu(x)) collapses the left-hand side into an exact product derivative: ddx[μ(x)y]=μ(x)Q(x)\dfrac{d}{dx}\bigl[\mu(x)y\bigr] = \mu(x)Q(x).

Worked Example 7.A — Probability & Cross-Entropy Calculation

A medical AI model has learned weights w=0.8 w = 0.8 and bias b=−2.4 b = -2.4 for predicting whether a tumor is malignant (y=1 y=1 ) based on diameter x x in cm:
z=0.8x−2.4,y^=σ(z) z = 0.8x - 2.4, \quad \hat{y} = \sigma(z)
(a) Find the predicted malignancy probability for a tumor of diameter x=4.5 cm x = 4.5 \text{ cm} .
(b) If the actual diagnosis was malignant (y=1 y = 1 ), calculate the binary cross-entropy loss L L .

Solution:
(a) Compute logit z z :
z=0.8(4.5)−2.4=3.6−2.4=1.2 z = 0.8(4.5) - 2.4 = 3.6 - 2.4 = 1.2 .
Compute probability via Sigmoid:
y^=σ(1.2)=11+e−1.2=11+0.3012=11.3012≈0.7685 \hat{y} = \sigma(1.2) = \frac{1}{1 + e^{-1.2}} = \frac{1}{1 + 0.3012} = \frac{1}{1.3012} \approx 0.7685 (76.85% probability).

(b) Binary cross-entropy with y=1 y = 1 :
L=−[1⋅ln⁡(0.7685)+0⋅ln⁡(1−0.7685)]=−ln⁡(0.7685)≈−(−0.2633)=0.2633 L = -\Big[ 1 \cdot \ln(0.7685) + 0 \cdot \ln(1 - 0.7685) \Big] = -\ln(0.7685) \approx -(-0.2633) = 0.2633 .
Answer: (a) y^≈0.769 \hat{y} \approx 0.769 (76.9%), (b) Loss L≈0.263 L \approx 0.263 .

Worked Example BB — Logistic Regression & Classification Boundaries (Hard Application)

Problem (Hard): Consider a binary classification problem where the decision boundary is defined by the logistic function p(x)=11+e−(β0+β1x1+β2x2) p(x) = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)}} , which represents the probability of a data point x=(x1,x2) \mathbf{x} = (x_1, x_2) belonging to class 1. The estimated model parameters are β0=−3 \beta_0 = -3 , β1=1 \beta_1 = 1 , and β2=−2 \beta_2 = -2 . We are interested in the geometric shape of the classification boundary. The classification boundary occurs where p(x)=0.5 p(x) = 0.5 . Find the equation of this boundary in the x1x2 x_1x_2 -plane.

Step-by-Step Solution: The logistic regression model gives the probability of belonging to class 1 as p(x)=11+e−(β0+β1x1+β2x2) p(x) = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)}} . The classification boundary is the set of points where p(x)=0.5 p(x) = 0.5 . Setting p(x)=0.5 p(x) = 0.5 , we have: 0.5=11+e−(β0+β1x1+β2x2) 0.5 = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)}} This implies: 1+e−(β0+β1x1+β2x2)=2 1 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)} = 2 Therefore: e−(β0+β1x1+β2x2)=1 e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)} = 1 Taking the natural logarithm of both sides: −(β0+β1x1+β2x2)=ln⁡(1) -(\beta_0 + \beta_1 x_1 + \beta_2 x_2) = \ln(1) Since ln⁡(1)=0 \ln(1) = 0 , we get: β0+β1x1+β2x2=0 \beta_0 + \beta_1 x_1 + \beta_2 x_2 = 0 This is the equation of the linear decision boundary. Substitute the given parameter values: β0=−3 \beta_0 = -3 , β1=1 \beta_1 = 1 , and β2=−2 \beta_2 = -2 . −3+x1+(−2)⋅x2=0 -3 + x_1 + (-2) \cdot x_2 = 0 −3+x1−2x2=0 -3 + x_1 - 2x_2 = 0 We need to express this in the form x2=f(x1) x_2 = f(x_1) . 2x2=x1−3 2x_2 = x_1 - 3 x2=12x1−32 x_2 = \frac{1}{2} x_1 - \frac{3}{2} This matches choice A.

Worked Example CC — Logistic Regression & Classification Boundaries (Easy Application)

Problem (Easy): Consider a simple logistic regression model where the decision boundary is defined by the linear equation w1x1+w2x2+b=0w_1x_1 + w_2x_2 + b = 0. If the weights are w1=2w_1 = 2 and w2=3w_2 = 3, and the bias is b=−7b = -7, what is the equation of the decision boundary?

Step-by-Step Solution: The decision boundary in a logistic regression model is defined by the equation where the log-odds are zero. This corresponds to a linear combination of the input features and weights, plus the bias, being equal to zero. Given the weights w1=2w_1 = 2 and w2=3w_2 = 3, and the bias b=−7b = -7, the equation of the decision boundary is w1x1+w2x2+b=0w_1x_1 + w_2x_2 + b = 0. Substituting the given values, we get 2x1+3x2+(−7)=02x_1 + 3x_2 + (-7) = 0, which simplifies to 2x1+3x2−7=02x_1 + 3x_2 - 7 = 0.

Worked Example DD — Logistic Regression & Classification Boundaries (Medium Application)

Problem (Medium): Consider a simple logistic regression model where the decision boundary is defined by the equation −1.5x1+2x2+5=0 -1.5x_1 + 2x_2 + 5 = 0 . For a data point (x1,x2) (x_1, x_2) , if \( -1.5x_1 + 2x_2 + 5 < 0 \), it is classified into Class 0. Otherwise, it is classified into Class 1. Which of the following points lies on the decision boundary?

Step-by-Step Solution: The decision boundary is defined by the equation −1.5x1+2x2+5=0 -1.5x_1 + 2x_2 + 5 = 0 . To find which point lies on the boundary, we substitute the coordinates of each point into the equation. For point (−1,1) (-1, 1) : −1.5(−1)+2(1)+5=1.5+2+5=8.5 -1.5(-1) + 2(1) + 5 = 1.5 + 2 + 5 = 8.5 , which is not 0. For point (2,−2) (2, -2) : −1.5(2)+2(−2)+5=−3−4+5=−2 -1.5(2) + 2(-2) + 5 = -3 - 4 + 5 = -2 , which is not 0. For point (0,−2.5) (0, -2.5) : −1.5(0)+2(−2.5)+5=0−5+5=0 -1.5(0) + 2(-2.5) + 5 = 0 - 5 + 5 = 0 . This point lies on the boundary. For point (3,0.5) (3, 0.5) : −1.5(3)+2(0.5)+5=−4.5+1+5=1.5 -1.5(3) + 2(0.5) + 5 = -4.5 + 1 + 5 = 1.5 , which is not 0. Therefore, the point (0,−2.5) (0, -2.5) lies on the decision boundary.

⚠️ Common Exam Traps — Logistic Regression & Classification Boundaries

1. Adding +C+C Only After Exponentiating in Separable ODEs: In dydx=3xy\dfrac{dy}{dx} = 3xy, integrating gives ln⁡∣y∣=32x2+C  ⟹  y=Ae3x2/2\ln|y| = \tfrac{3}{2}x^2 + C \implies y = Ae^{3x^2/2} where A=±eCA = \pm e^C. Writing y=e3x2/2+Cy = e^{3x^2/2} + C is a fatal algebraic error that forfeits all follow-up marks on Mathematics for Artificial Intelligence & Machine Learning.

2. Forgetting to Transform Limits in uu-Substitution: In definite integrals ∫abf(g(x))g′(x) dx\int_a^b f(g(x))g'(x)\,dx, you must replace the limits x=a,bx = a, b with u=g(a),g(b)u = g(a), g(b) immediately.

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Logistic Regression & Classification Boundaries)
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Writing ln⁡∣y∣=x2+C  ⟹  y=ex2+C\ln|y| = x^2 + C \implies y = e^{x^2} + C Exponentiation distributes over addition as multiplication (ea+b=eaebe^{a+b} = e^a e^b), not addition. Write y=ex2+C=Aex2y = e^{x^2 + C} = Ae^{x^2} and solve for AA using the initial condition.
Leaving original xx-limits on a uu-substituted definite integral Evaluates the antiderivative F(u)F(u) at xx-values instead of u(x)u(x)-values. Convert bounds immediately: ulow=u(a)u_{\text{low}} = u(a) and uhigh=u(b)u_{\text{high}} = u(b).
Computing total distance as ∣∫t1t2v(t) dt∣\left|\int_{t_1}^{t_2} v(t)\,dt\right| Cancels forward and backward motion (net displacement) instead of accumulating total path length. Split the integral at every root where v(t)=0v(t) = 0 and integrate ∣v(t)∣|v(t)|.
▲ Exam Pacing & Verification Strategy — Logistic Regression & Classification Boundaries

Quick Verification Trick (Mathematics for Artificial Intelligence & Machine Learning): For any indefinite integral ∫f(x) dx=F(x)+C\int f(x)\,dx = F(x) + C, differentiate your answer F′(x)F'(x) mentally—especially the coefficient 1/k1/k from chain-rule reversal ∫ekx dx=1kekx+C\int e^{kx}\,dx = \tfrac{1}{k}e^{kx} + C—before moving on.

[Practice 1 · Hard] The sigmoid activation function is σ(z)=11+e−z \sigma(z) = \frac{1}{1 + e^{-z}} . If σ(z0)=0.40 \sigma(z_0) = 0.40 , what is the value of the derivative σ′(z0) \sigma'(z_0) ?
💡 Hint 1 of 3
The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)) \sigma'(z) = \sigma(z)(1 - \sigma(z)) .
💡 Hint 2 of 3
Substituting σ(z0)=0.40 \sigma(z_0) = 0.40 : σ′(z0)=(0.40)(1−0.40)\sigma'(z_0) = (0.40)(1 - 0.40). Substitute and simplify: σ′(z0)=(0.40)(0.60)\sigma'(z_0) = (0.40)(0.60).
💡 Hint 3 of 3
Compute the final value from: (0.40)(0.60)(0.40)(0.60).
The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z)) \sigma'(z) = \sigma(z)(1 - \sigma(z)) . Substituting σ(z0)=0.40 \sigma(z_0) = 0.40 : σ′(z0)=(0.40)(1−0.40)=(0.40)(0.60)=0.2400 \sigma'(z_0) = (0.40)(1 - 0.40) = (0.40)(0.60) = 0.2400 .
[Practice 2 · Easy] A fitted simple linear regression model is y^=7x+18 \hat{y} = 7x + 18 . What is the predicted target value y^ \hat{y} when the input feature is x=4 x = 4 ?
💡 Hint 1 of 3
Substitute x=4 x = 4 into the regression equation: y^=7(4)+18\hat{y} = 7(4) + 18.
💡 Hint 2 of 3
Substitute and simplify: y^=28+18\hat{y} = 28 + 18.
💡 Hint 3 of 3
Compute the final value from: 28+1828 + 18.
Substitute x=4 x = 4 into the regression equation: y^=7(4)+18=28+18=46 \hat{y} = 7(4) + 18 = 28 + 18 = 46 .
[Practice 3 · Medium] A binary classification model uses a logistic sigmoid function σ(z)=11+e−z \sigma(z) = \frac{1}{1 + e^{-z}} . The decision boundary is defined by σ(z)=0.5 \sigma(z) = 0.5 , where z=w1x1+w0 z = w_1 x_1 + w_0 . For a dataset with two features x1 x_1 and x2 x_2 , the model's linear component is z=2x1−x2+b z = 2x_1 - x_2 + b . If the classification boundary passes through the point (x1,x2)=(3,1) (x_1, x_2) = (3, 1) , what is the value of the bias b b ?
💡 Hint 1 of 3
The logistic sigmoid function is σ(z)=11+e−z \sigma(z) = \frac{1}{1 + e^{-z}} . The decision boundary is where σ(z)=0.5 \sigma(z) = 0.5 . Setting σ(z)=0.5 \sigma(z) = 0.5 gives 11+e−z=0.5 \frac{1}{1 + e^{-z}} = 0.5 , which implies 1=0.5(1+e−z) 1 = 0.5(1 + e^{-z}) , so 2=1+e−z 2 = 1 + e^{-z} , and e−z=1 e^{-z} = 1 . This occurs when −z=0 -z = 0 , or z=0 z = 0 . Therefore, the decision boundary is defined by z=0 z = 0 .
💡 Hint 2 of 3
The linear component of the model is given by z=w1x1+w2x2+b z = w_1 x_1 + w_2 x_2 + b . In this problem, z=2x1−x2+b z = 2x_1 - x_2 + b . Since the decision boundary is z=0 z = 0 , we have 2x1−x2+b=0 2x_1 - x_2 + b = 0 .
💡 Hint 3 of 3
Use the resulting form to finish: 5+b5 + b.
The logistic sigmoid function is σ(z)=11+e−z \sigma(z) = \frac{1}{1 + e^{-z}} . The decision boundary is where σ(z)=0.5 \sigma(z) = 0.5 . Setting σ(z)=0.5 \sigma(z) = 0.5 gives 11+e−z=0.5 \frac{1}{1 + e^{-z}} = 0.5 , which implies 1=0.5(1+e−z) 1 = 0.5(1 + e^{-z}) , so 2=1+e−z 2 = 1 + e^{-z} , and e−z=1 e^{-z} = 1 . This occurs when −z=0 -z = 0 , or z=0 z = 0 . Therefore, the decision boundary is defined by z=0 z = 0 . The linear component of the model is given by z=w1x1+w2x2+b z = w_1 x_1 + w_2 x_2 + b . In this problem, z=2x1−x2+b z = 2x_1 - x_2 + b . Since the decision boundary is z=0 z = 0 , we have 2x1−x2+b=0 2x_1 - x_2 + b = 0 . The classification boundary passes through the point (x1,x2)=(3,1) (x_1, x_2) = (3, 1) . Substituting these values into the equation for the decision boundary: 2(3)−1+b=0 2(3) - 1 + b = 0 6−1+b=0 6 - 1 + b = 0 5+b=0 5 + b = 0 b=−5 b = -5
[Practice 4 · Hard] For a bivariate feature dataset, Cov(x,y)=24 \text{Cov}(x, y) = 24 , Var(x)=8 \text{Var}(x) = 8 , xˉ=5 \bar{x} = 5 , and yˉ=30 \bar{y} = 30 . Compute the OLS regression slope β^1 \hat{\beta}_1 and intercept β^0 \hat{\beta}_0 .
💡 Hint 1 of 3
The OLS slope is β^1=Cov(x,y)Var(x)=248\hat{\beta}_1 = \frac{\text{Cov}(x, y)}{\text{Var}(x)} = \frac{24}{8}.
💡 Hint 2 of 3
The intercept is: β^0=yˉ−β^1xˉ\hat{\beta}_0 = \bar{y} - \hat{\beta}_1\bar{x}. Substitute and simplify: β^0=30−(3)(5)\hat{\beta}_0 = 30 - (3)(5).
💡 Hint 3 of 3
Compute the final value from: 30−1530 - 15.
The OLS slope is β^1=Cov(x,y)Var(x)=248=3 \hat{\beta}_1 = \frac{\text{Cov}(x, y)}{\text{Var}(x)} = \frac{24}{8} = 3 . The intercept is β^0=yˉ−β^1xˉ=30−(3)(5)=30−15=15 \hat{\beta}_0 = \bar{y} - \hat{\beta}_1\bar{x} = 30 - (3)(5) = 30 - 15 = 15 .
[Practice 5 · Easy] In evaluating a binary classifier, the confusion matrix shows TP=45 TP = 45 , TN=40 TN = 40 , FP=10 FP = 10 , and FN=10 FN = 10 . Compute the overall classification accuracy.
💡 Hint 1 of 3
Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TNTP+TN+FP+FN\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}.
💡 Hint 2 of 3
Substitute and simplify: Accuracy=45+40105\text{Accuracy} = \frac{45 + 40}{105}.
💡 Hint 3 of 3
Compute the final value from: 45+40105\frac{45 + 40}{105}.
Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TNTP+TN+FP+FN=45+40105=85105=81.0% \text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN} = \frac{45 + 40}{105} = \frac{85}{105} = 81.0\% .
📝 Chapter Quiz
8

Dimensionality Reduction, Covariance & PCA

🤖 AI Math Unit 8 — Dimensionality Reduction & PCA Applied STEM  ·  Curse of dimensionality in high-dimensional data  ·  Sample covariance matrix Σ  ·  Eigenvalues λ and Eigenvectors v  ·  Principal Component Analysis (PCA) projection  ·  Explained variance ratio and data compression

Real datasets frequently have hundreds or thousands of correlated features. Principal Component Analysis (PCA) identifies the orthogonal axes of maximum variance, compressing high-dimensional data while preserving essential information.

الشرح الرياضي (تقليل الأبعاد ومصفوفة التباين المشترك وتحليل المكونات الرئيسية (PCA)):

Real datasets frequently have hundreds or thousands of correlated features. Principal Component Analysis (PCA) identifies the orthogonal axes of maximum variance, compressing high-dimensional data while preserving essential information.

▲ Theorem 8.1 — PCA via Spectral Decomposition
Let X∈RN×d \mathbf{X} \in \mathbb{R}^{N \times d} be a zero-centered data matrix (mean xˉ=0 \mathbf{\bar{x}} = \mathbf{0} ).
1. The empirical covariance matrix is Σ=1N−1XTX∈Rd×d \mathbf{\Sigma} = \frac{1}{N-1} \mathbf{X}^T \mathbf{X} \in \mathbb{R}^{d \times d} .
2. Because Σ \mathbf{\Sigma} is symmetric positive semi-definite, it admits an orthonormal eigen-decomposition:
Σvi=λivi,λ1≥λ2≥⋯≥λd≥0 \mathbf{\Sigma} \mathbf{v}_i = \lambda_i \mathbf{v}_i, \quad \lambda_1 \ge \lambda_2 \ge \dots \ge \lambda_d \ge 0
3. The first principal component v1 \mathbf{v}_1 is the unit eigenvector associated with the largest eigenvalue λ1 \lambda_1 , maximizing the variance of the projected data.
● Deep Conceptual Intuition — Dimensionality Reduction, Covariance & PCA

Linear Structure, Inner Products & Geometric Transformations: In Rn\mathbb{R}^n, the dot product u⋅v=∥u∥∥v∥cos⁡θ=∑i=1nuivi\mathbf{u}\cdot\mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos\theta = \sum_{i=1}^n u_i v_i encodes orthogonality (u⊥v  ⟺  u⋅v=0\mathbf{u}\perp\mathbf{v} \iff \mathbf{u}\cdot\mathbf{v} = 0) and orthogonal projection proj⁡vu=u⋅v∥v∥2v\operatorname{proj}_{\mathbf{v}}\mathbf{u} = \dfrac{\mathbf{u}\cdot\mathbf{v}}{\|\mathbf{v}\|^2}\mathbf{v}. For a matrix transformation A∈Rn×nA \in \mathbb{R}^{n\times n}, ∣det⁡(A)∣|\det(A)| measures the local volume scaling factor, and AA is invertible if and only if det⁡(A)≠0\det(A) \ne 0 (equivalently, all eigenvalues λi≠0\lambda_i \ne 0).

Coordinate transformation grid showing object and transformed image: Dimensionality Reduction, Covariance & PCA — Linear Transformation & Basis Action-6-4-2246-6-4-2246ABCA′B′C′Linear Transformation & Basis Action
Coordinate grid showing geometric action of a linear transformation mapping △ABC to its image △A'B'C'.
⊙ Explorer · PCA: Covariance Point Cloud, Principal Axis v1v_{1} & Projections
interactive
Projected Variance along u(θ)u(\theta)Var_θ=1.752\theta = 1.752
Optimal First Eigenvector θ\theta*θ∗=45.0∘\theta * = 45.0^\circ
Explained Variance RatioEVR1=90.0%EVR_{1} = 90.0\%

Rotate unit direction vector u(θ)u(\theta) through the centered 2D data cloud. PCA chooses the angle θ\theta* that maximizes the variance of the orthogonal projections (and minimizes perpendicular reconstruction error).

Bar chart with categories: (), ()021436485PC185PC215
Dimensionality Reduction, Covariance & PCA — Mathematical Diagram (2) — illustrating key geometric and analytical relationships in Dimensionality Reduction, Covariance & PCA.
Covariance Entry
Cov(X,Y)=1N−1∑(xi−xˉ)(yi−yˉ) \text{Cov}(X, Y) = \frac{1}{N-1}\sum (x_i - \bar{x})(y_i - \bar{y})
Characteristic Equation
det⁡(Σ−λI)=0 \det(\mathbf{\Sigma} - \lambda \mathbf{I}) = 0
Explained Variance
Ratiok=λk∑j=1dλj \text{Ratio}_k = \frac{\lambda_k}{\sum_{j=1}^d \lambda_j}
Projection
z=VkTx∈Rk \mathbf{z} = \mathbf{V}_k^T \mathbf{x} \in \mathbb{R}^k (reduced representation)
◆ Why It Works — First-Principles Derivation (Dimensionality Reduction, Covariance & PCA)

Why Orthogonal Projection & Eigenvalue Characteristic Equations Work: Decompose u=cv+w\mathbf{u} = c\mathbf{v} + \mathbf{w} where w⊥v\mathbf{w} \perp \mathbf{v}. Taking the dot product with v\mathbf{v} uses w⋅v=0\mathbf{w}\cdot\mathbf{v} = 0 to isolate cc:

u⋅v=c(v⋅v)+0  ⟹  c=u⋅v∥v∥2 \mathbf{u}\cdot\mathbf{v} = c(\mathbf{v}\cdot\mathbf{v}) + 0 \implies c = \frac{\mathbf{u}\cdot\mathbf{v}}{\|\mathbf{v}\|^2}

For eigenvalues, Av=λvA\mathbf{v} = \lambda\mathbf{v} with v≠0\mathbf{v} \ne \mathbf{0} is equivalent to (A−λI)v=0(A - \lambda I)\mathbf{v} = \mathbf{0}. A homogeneous linear system has a non-trivial nullspace vector v≠0\mathbf{v} \ne \mathbf{0} if and only if the matrix A−λIA - \lambda I is singular, yielding the characteristic polynomial det⁡(A−λI)=0\det(A - \lambda I) = 0.

Worked Example 8.A — Finding Principal Components of 2D Data

A 2D centered dataset has sample covariance matrix:
Σ=(4221) \mathbf{\Sigma} = \begin{pmatrix} 4 & 2 \\ 2 & 1 \end{pmatrix}
(a) Find the eigenvalues λ1 \lambda_1 and λ2 \lambda_2 .
(b) Find the unit eigenvector v1 \mathbf{v}_1 corresponding to the principal component.
(c) What percentage of total variance is explained by the first principal component?

Solution:
(a) Characteristic equation det⁡(Σ−λI)=0 \det(\mathbf{\Sigma} - \lambda\mathbf{I}) = 0 :
det⁡(4−λ221−λ)=(4−λ)(1−λ)−(2)(2)=0 \det \begin{pmatrix} 4 - \lambda & 2 \\ 2 & 1 - \lambda \end{pmatrix} = (4 - \lambda)(1 - \lambda) - (2)(2) = 0
λ2−5λ+4−4=0  ⟹  λ2−5λ=0  ⟹  λ(λ−5)=0 \lambda^2 - 5\lambda + 4 - 4 = 0 \implies \lambda^2 - 5\lambda = 0 \implies \lambda(\lambda - 5) = 0 .
Eigenvalues are λ1=5 \lambda_1 = 5 and λ2=0 \lambda_2 = 0 .

(b) For λ1=5 \lambda_1 = 5 :
(Σ−5I)v=(−122−4)(v1v2)=(00)  ⟹  −v1+2v2=0  ⟹  v1=2v2 (\mathbf{\Sigma} - 5\mathbf{I})\mathbf{v} = \begin{pmatrix} -1 & 2 \\ 2 & -4 \end{pmatrix} \begin{pmatrix} v_1 \\ v_2 \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \end{pmatrix} \implies -v_1 + 2v_2 = 0 \implies v_1 = 2v_2 .
A directional vector is (21) \begin{pmatrix} 2 \\ 1 \end{pmatrix} . Normalizing to unit length:
∥v∥=22+12=5  ⟹  v1=15(21)=(2/51/5)≈(0.8940.447) \|\mathbf{v}\| = \sqrt{2^2 + 1^2} = \sqrt{5} \implies \mathbf{v}_1 = \frac{1}{\sqrt{5}}\begin{pmatrix} 2 \\ 1 \end{pmatrix} = \begin{pmatrix} 2/\sqrt{5} \\ 1/\sqrt{5} \end{pmatrix} \approx \begin{pmatrix} 0.894 \\ 0.447 \end{pmatrix} .

(c) Total variance = λ1+λ2=5+0=5 \lambda_1 + \lambda_2 = 5 + 0 = 5 .
Percentage explained = 55=100% \frac{5}{5} = 100\% . (The data lies perfectly along a 1D line in 2D space!).
Answer: λ1=5, λ2=0 \lambda_1 = 5, \, \lambda_2 = 0 ; v1=[0.894,0.447]T \mathbf{v}_1 = [0.894, 0.447]^T ; 100% variance explained.

Worked Example BB — Dimensionality Reduction, Covariance & PCA (Easy Application)

Problem (Easy): Consider a 2D data point v=[3−4] \mathbf{v} = \begin{bmatrix} 3 \\ -4 \end{bmatrix} . What is the squared Euclidean norm (or squared magnitude) of this vector?

Step-by-Step Solution: The squared Euclidean norm of a vector v=[v1v2] \mathbf{v} = \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} is given by ∥v∥2=v12+v22 \|\mathbf{v}\|^2 = v_1^2 + v_2^2 . For the given vector v=[3−4] \mathbf{v} = \begin{bmatrix} 3 \\ -4 \end{bmatrix} , the squared Euclidean norm is (3)2+(−4)2=9+16=25 (3)^2 + (-4)^2 = 9 + 16 = 25 .

Worked Example CC — Dimensionality Reduction, Covariance & PCA (Medium Application)

Problem (Medium): A binary classifier p(t) p(t) produces the confusion matrix below with TP=68 \text{TP} = 68 , FP=10 \text{FP} = 10 , FN=48 \text{FN} = 48 , and TN=80 \text{TN} = 80 . Determine the total number of correct classifications q=TP+TN q = \text{TP} + \text{TN} .

Step-by-Step Solution: Summing TP+TN=68+80=148 \text{TP} + \text{TN} = 68 + 80 = 148 .

Worked Example DD — Dimensionality Reduction, Covariance & PCA (Hard Application)

Problem (Hard): Consider a 2D dataset represented by the points A=(1,2) A = (1, 2) , B=(4,2) B = (4, 2) , and C=(2,5) C = (2, 5) . If this dataset undergoes a linear transformation represented by the matrix M=(2001) M = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} , what are the coordinates of the transformed points A′ A' , B′ B' , and C′ C' ?

Step-by-Step Solution: The transformation of a point x \mathbf{x} by a matrix M M is given by Mx M \mathbf{x} . We apply the matrix M=(2001) M = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} to each point: For point A=(1,2) A = (1, 2) , the transformed point A′ A' is: (2001)(12)=(2×1+0×20×1+1×2)=(22) \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} 1 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 \times 1 + 0 \times 2 \\ 0 \times 1 + 1 \times 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 2 \end{pmatrix} So, A′=(2,2) A' = (2, 2) . For point B=(4,2) B = (4, 2) , the transformed point B′ B' is: (2001)(42)=(22) \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} 4 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 2 \end{pmatrix} So, B′=(8,2) B' = (8, 2) . For point C=(2,5) C = (2, 5) , the transformed point C′ C' is: (2001)(25)=(2×2+0×50×2+1×5)=(45) \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} 2 \\ 5 \end{pmatrix} = \begin{pmatrix} 2 \times 2 + 0 \times 5 \\ 0 \times 2 + 1 \times 5 \end{pmatrix} = \begin{pmatrix} 4 \\ 5 \end{pmatrix} So, C′=(4,5) C' = (4, 5) . Therefore, the transformed points are A′=(2,2) A' = (2, 2) , B′=(8,2) B' = (8, 2) , and C′=(4,5) C' = (4, 5) .

⚠️ Common Exam Traps — Dimensionality Reduction, Covariance & PCA

1. Non-Commutativity of Matrix Multiplication & Cross Products: On Mathematics for Artificial Intelligence & Machine Learning, assuming AB=BAAB = BA (so expanding (A+B)2(A+B)^2 as A2+2AB+B2A^2 + 2AB + B^2 instead of A2+AB+BA+B2A^2 + AB + BA + B^2) or forgetting u×v=−(v×u)\mathbf{u}\times\mathbf{v} = -(\mathbf{v}\times\mathbf{u}) invalidates matrix proofs.

2. Using Position Vectors Instead of Direction Vectors for Angles: To find the angle at vertex BB of triangle ABCABC, you must use tail-to-tail vectors BA→\overrightarrow{BA} and BC→\overrightarrow{BC}, never AB→⋅BC→\overrightarrow{AB}\cdot\overrightarrow{BC} (which finds the exterior supplementary angle 180∘−B180^\circ - B).

Error Diagnosis — Common Student Traps vs. Exam-Board Method (Dimensionality Reduction, Covariance & PCA)
Common Student Trap Why It Fails Mathematically Correct Exam-Board Method
Computing angle at BB using AB→⋅BC→\overrightarrow{AB}\cdot\overrightarrow{BC} Vectors are head-to-tail instead of tail-to-tail, giving 180∘−θ180^\circ - \theta. Reverse AB→\overrightarrow{AB} so both emanate from BB: use BA→⋅BC→\overrightarrow{BA}\cdot\overrightarrow{BC}.
Using the same parameter tt for two intersecting 3D lines r1(t)=r2(t)\mathbf{r}_1(t) = \mathbf{r}_2(t) Tests for a simultaneous collision at time tt rather than geometric intersection of paths. Assign distinct parameters λ\lambda and μ\mu to the two lines before equating components.
Assuming (AB)−1=A−1B−1(AB)^{-1} = A^{-1}B^{-1} Multiplying (AB)(A−1B−1)(AB)(A^{-1}B^{-1}) does not cancel inner factors when AB≠BAAB \ne BA. Use the shoe-sock reversal law: (AB)−1=B−1A−1(AB)^{-1} = B^{-1}A^{-1}.
▲ Exam Pacing & Verification Strategy — Dimensionality Reduction, Covariance & PCA

Fast Matrix & Vector Verification (Mathematics for Artificial Intelligence & Machine Learning): Check every 2×22\times 2 or 3×33\times 3 eigenvalue computation using the trace and determinant invariants: ∑λi=tr⁡(A)\sum \lambda_i = \operatorname{tr}(A) (sum of diagonal entries) and ∏λi=det⁡(A)\prod \lambda_i = \det(A).

[Practice 1 · Easy] Consider a dataset of observations {xi}i=1n\{x_i\}_{i=1}^n where each xix_i is a 2-dimensional vector. The sample covariance matrix for this dataset is given by: S=(4−2−21) S = \begin{pmatrix} 4 & -2 \\ -2 & 1 \end{pmatrix} Principal Component Analysis (PCA) is applied to this dataset. The first principal component corresponds to the direction with the largest variance. Let the direction vector of the first principal component be v1=(ab)\mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix}. The variance explained by this principal component is given by the corresponding eigenvalue λ1\lambda_1. If v1\mathbf{v}_1 is a unit vector, what is the value of a2+b2a^2+b^2?
💡 Hint 1 of 3
The first principal component direction vector v1\mathbf{v}_1 is an eigenvector of the covariance matrix SS.
💡 Hint 2 of 3
The variance explained by this component is the corresponding eigenvalue λ1\lambda_1. The problem states that v1=(ab)\mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix} is a unit vector.
💡 Hint 3 of 3
The specific values of aa and bb and the eigenvalues of SS are not needed to answer this question, as it directly asks for the property of a unit vector.
The first principal component direction vector v1\mathbf{v}_1 is an eigenvector of the covariance matrix SS. The variance explained by this component is the corresponding eigenvalue λ1\lambda_1. The problem states that v1=(ab)\mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix} is a unit vector. By definition, a unit vector has a magnitude of 1. The squared magnitude of a vector (ab)\begin{pmatrix} a \\ b \end{pmatrix} is a2+b2a^2 + b^2. Therefore, if v1\mathbf{v}_1 is a unit vector, its squared magnitude must be 1, which means a2+b2=1a^2 + b^2 = 1. The specific values of aa and bb and the eigenvalues of SS are not needed to answer this question, as it directly asks for the property of a unit vector.
[Practice 2 · Medium] Consider a dataset of n n data points, each residing in RD \mathbb{R}^D . We are performing Principal Component Analysis (PCA) to reduce the dimensionality. The first three principal components capture 70% 70\% of the total variance, the first six capture 85% 85\% , and the first ten capture 92% 92\% . You are tasked with selecting a subset of principal components for a downstream machine learning model. If the model requires that at least 90% 90\% of the original variance be retained, and you want to use the minimum possible number of principal components, what is the dimensionality of the transformed data?
💡 Hint 1 of 3
The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90% 90\% . The provided information states: - The first 3 principal components capture 70% 70\% of the variance.
💡 Hint 2 of 3
- The first 6 principal components capture 85% 85\% of the variance. - The first 10 principal components capture 92% 92\% of the variance.
💡 Hint 3 of 3
Therefore, the minimum number of principal components required to retain at least 90%90\% of the variance is 10. When PCA reduces the dimensionality of data from RD\mathbb{R}^D to Rk\mathbb{R}^k using the top kk principal components, the dimension of each transformed data point is kk. In this case, kk.
The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90% 90\% . The provided information states: - The first 3 principal components capture 70% 70\% of the variance. - The first 6 principal components capture 85% 85\% of the variance. - The first 10 principal components capture 92% 92\% of the variance. We need to find the smallest k k such that the cumulative variance captured by the first k k principal components is ≥90% \ge 90\% . Checking the given values: - For k=3 k = 3 , variance captured = 70% 70\% , which is less than 90% 90\% . - For k=6 k = 6 , variance captured = 85% 85\% , which is less than 90% 90\% . - For k=10 k = 10 , variance captured = 92% 92\% , which is greater than or equal to 90% 90\% . Therefore, the minimum number of principal components required to retain at least 90% 90\% of the variance is 10. When PCA reduces the dimensionality of data from RD \mathbb{R}^D to Rk \mathbb{R}^k using the top k k principal components, the dimension of each transformed data point is k k . In this case, k=10 k=10 .
[Practice 3 · Hard] In training a language model token predictor, a binary token occurs k=6 k = 6 times across n=20 n = 20 independent trials. What is the Maximum Likelihood Estimate p^MLE \hat{p}_{\text{MLE}} of the token probability?
💡 Hint 1 of 3
For a Bernoulli likelihood L(p)=pk(1−p)n−k L(p) = p^k (1-p)^{n-k} , the log-likelihood is ln⁡L=kln⁡p+(n−k)ln⁡(1−p) \ln L = k\ln p + (n-k)\ln(1-p) .
💡 Hint 2 of 3
Setting derivative to zero: kp−n−k1−p=0\frac{k}{p} - \frac{n-k}{1-p} = 0. Substitute and simplify: p^=kn\hat{p} = \frac{k}{n}.
💡 Hint 3 of 3
Evaluate the simplified expression: p^=620\hat{p} = \frac{6}{20}.
For a Bernoulli likelihood L(p)=pk(1−p)n−k L(p) = p^k (1-p)^{n-k} , the log-likelihood is ln⁡L=kln⁡p+(n−k)ln⁡(1−p) \ln L = k\ln p + (n-k)\ln(1-p) . Setting derivative to zero: kp−n−k1−p=0  ⟹  p^=kn=620=0.300 \frac{k}{p} - \frac{n-k}{1-p} = 0 \implies \hat{p} = \frac{k}{n} = \frac{6}{20} = 0.300 .
[Practice 4 · Easy] An Ordinary Least Squares linear model p^(t)=2t+11 \hat{p}(t) = 2t + 11 is evaluated at t=3 t = 3 . Determine the predicted response p^(3) \hat{p}(3) .
💡 Hint 1 of 3
Start from the given mathematical expression in the prompt: p^(t)=2t+11\hat{p}(t) = 2t + 11.
💡 Hint 2 of 3
Write out the unsimplified expression: 2(3)+112(3) + 11.
💡 Hint 3 of 3
Perform the arithmetic in 2(3)+112(3) + 11 to find the final value.
Evaluating 2(3)+11=17 2(3) + 11 = 17 .
[Practice 5 · Medium] A machine learning diagnostic test has sensitivity P(Positive∣Defect)=0.90 P(\text{Positive} | \text{Defect}) = 0.90 . If the defect rate in production is P(Defect)=0.10 P(\text{Defect}) = 0.10 , find the joint probability of a defect and a positive test result P(Defect∩Positive) P(\text{Defect} \cap \text{Positive}) .
💡 Hint 1 of 3
By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect)P(\text{Defect} \cap \text{Positive}) = P(\text{Defect}) \times P(\text{Positive} | \text{Defect}).
💡 Hint 2 of 3
Substitute and simplify: P(Defect∩Positive)=0.10×0.90P(\text{Defect} \cap \text{Positive}) = 0.10 \times 0.90.
💡 Hint 3 of 3
Compute the final value from: 0.10×0.900.10 \times 0.90.
By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect)=0.10×0.90=0.0900 P(\text{Defect} \cap \text{Positive}) = P(\text{Defect}) \times P(\text{Positive} | \text{Defect}) = 0.10 \times 0.90 = 0.0900 .
📝 Chapter Quiz
§

Practice set

Fifty applied mathematics problems for AI & Data Science spanning high-dimensional vectors and cosine similarity, neural layer matrix transformations, multivariable calculus and gradient descent optimization, conditional probability and Bayes' theorem, probability distributions and maximum likelihood estimation (MLE), ordinary least squares linear regression, logistic regression and cross-entropy loss, and covariance matrices and Principal Component Analysis (PCA).

1

In anomaly detection, anomaly prior P(A)=0.02P(A) = 0.02, detection sensitivity P(+∣A)=0.95P(+|A) = 0.95, and false alarm rate P(+∣¬A)=0.05P(+|\neg A) = 0.05. By Bayes' theorem, what is the posterior probability P(A∣+)P(A|+) that an alarm is a true anomaly?

Advanced
Probability tree diagram: Two-Stage Probability TreeTwo-Stage Probability TreepAqB | AA ∩ B1-qB' | AA ∩ B'1-pA'rB | A'A' ∩ B1-rB' | A'A' ∩ B'

By Bayes' Rule: P(A∣+)=P(+∣A)P(A)P(+∣A)P(A)+P(+∣¬A)P(¬A)=0.95×0.020.95(0.02)+0.05(0.98)=0.01900.0680=0.279P(A|+) = \frac{P(+|A)P(A)}{P(+|A)P(A) + P(+|\neg A)P(\neg A)} = \frac{0.95 \times 0.02}{0.95(0.02) + 0.05(0.98)} = \frac{0.0190}{0.0680} = 0.279.

Final Answer: 0.2790.279

2

Consider a dataset of nn data points, each residing in RD\mathbb{R}^D. We are performing Principal Component Analysis (PCA) to reduce the dimensionality. The first three principal components capture 70%70\% of the total variance, the first six capture 85%85\%, and the first ten capture 92%92\%. You are tasked with selecting a subset of principal components for a downstream machine learning model. If the model requires that at least 90%90\% of the original variance be retained, and you want to use the minimum possible number of principal components, what is the dimensionality of the transformed data?

Advanced
Scatter plot: Bivariate Data & Trend; x: Predictor (x); y: Response (y)Bivariate Data & Trend123345134689Predictor (x)Response (y)(1, 2.1)(2, 3.8)(3, 5.2)(4, 6.9)(5, 8.4)

The problem requires us to find the minimum number of principal components such that the cumulative explained variance is at least 90%90\%. The provided information states:

- The first 3 principal components capture 70%70\% of the variance.
- The first 6 principal components capture 85%85\% of the variance.
- The first 10 principal components capture 92%92\% of the variance.

We need to find the smallest kk such that the cumulative variance captured by the first kk principal components is ≥90%\ge 90\%.

Checking the given values:
- For k=3k = 3, variance captured = 70%70\%, which is less than 90%90\%.
- For k=6k = 6, variance captured = 85%85\%, which is less than 90%90\%.
- For k=10k = 10, variance captured = 92%92\%, which is greater than or equal to 90%90\%.

Therefore, the minimum number of principal components required to retain at least 90%90\% of the variance is 10. When PCA reduces the dimensionality of data from RD\mathbb{R}^D to Rk\mathbb{R}^k using the top kk principal components, the dimension of each transformed data point is kk. In this case, k=10k=10.

3

Given n=12n = 12 independent observations from a normal distribution with sum ∑i=112xi=36\sum_{i=1}^{12} x_i = 36, what is the Maximum Likelihood Estimate (MLE) μ^MLE\hat{\mu}_{\text{MLE}}?

Intermediate
Normal distribution bell curve (mean 0, sd 1): Normal Distribution Model showing shaded probability regionNormal Distribution Model-3σ-2σ-1σ0+1σ+2σ+3σ

The log-likelihood ln⁡L(μ)=−n2ln⁡(2πσ2)−12σ2∑(xi−μ)2\ln L(\mu) = -\frac{n}{2}\ln(2\pi\sigma^2) - \frac{1}{2\sigma^2}\sum (x_i - \mu)^2. Setting ∂ln⁡L∂μ=0\frac{\partial \ln L}{\partial \mu} = 0 yields the sample mean μ^=1n∑xi=3612=3\hat{\mu} = \frac{1}{n}\sum x_i = \frac{36}{12} = 3.

Final Answer: μ^MLE=3\hat{\mu}_{\text{MLE}} = 3

4

Consider the scalar loss function L(w)=6w2−8w+5L(w) = 6w^2 - 8w + 5. Find the analytical gradient ∇L(w)\nabla L(w) evaluated at w=10w = 10.

Intermediate
Coordinate plane with graph of y = f(x); marked points A (0, 2), B (2, 1)-112313xyABy = f(x)

Differentiate with respect to ww: dLdw=2(6)w−8=12w−8\frac{dL}{dw} = 2(6)w - 8 = 12w - 8. At w=10w = 10: ∇L=12(10)−8=120−8=112\nabla L = 12(10) - 8 = 120 - 8 = 112.

Final Answer: ∇L(10)=112\nabla L(10) = 112

Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.

5

For a bivariate feature dataset, Cov(x,y)=36\text{Cov}(x, y) = 36, Var(x)=12\text{Var}(x) = 12, xˉ=5\bar{x} = 5, and yˉ=35\bar{y} = 35. Compute the OLS regression slope β^1\hat{\beta}_1 and intercept β^0\hat{\beta}_0.

Advanced
Scatter plot: Bivariate Data & Trend; x: Predictor (x); y: Response (y)Bivariate Data & Trend123345134689Predictor (x)Response (y)(1, 2.1)(2, 3.8)(3, 5.2)(4, 6.9)(5, 8.4)

The OLS slope is β^1=Cov(x,y)Var(x)=3612=3\hat{\beta}_1 = \frac{\text{Cov}(x, y)}{\text{Var}(x)} = \frac{36}{12} = 3. The intercept is β^0=yˉ−β^1xˉ=35−(3)(5)=35−15=20\hat{\beta}_0 = \bar{y} - \hat{\beta}_1\bar{x} = 35 - (3)(5) = 35 - 15 = 20.

Final Answer: β^1=3,  β^0=20\hat{\beta}_1 = 3, \; \hat{\beta}_0 = 20

6

A spam classification model identifies TP=120TP = 120 genuine spam emails and FP=40FP = 40 legitimate emails falsely flagged as spam. What is the precision of this model?

Intermediate

Precision is the fraction of predicted positive instances that are truly positive: Precision=TPTP+FP=120120+40=120160=75.0%\text{Precision} = \frac{TP}{TP + FP} = \frac{120}{120 + 40} = \frac{120}{160} = 75.0\%.

Final Answer: 75.0%75.0\%

7

Consider a binary classification problem where the decision boundary is defined by the logistic function p(x)=11+e−(β0+β1x1+β2x2)p(x) = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)}}, which represents the probability of a data point x=(x1,x2)\mathbf{x} = (x_1, x_2) belonging to class 1. The estimated model parameters are β0=−3\beta_0 = -3, β1=1\beta_1 = 1, and β2=−2\beta_2 = -2. We are interested in the geometric shape of the classification boundary. The classification boundary occurs where p(x)=0.5p(x) = 0.5. Find the equation of this boundary in the x1x2x_1x_2-plane.

Advanced

The logistic regression model gives the probability of belonging to class 1 as p(x)=11+e−(β0+β1x1+β2x2)p(x) = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)}}. The classification boundary is the set of points where p(x)=0.5p(x) = 0.5.

Setting p(x)=0.5p(x) = 0.5, we have:
0.5=11+e−(β0+β1x1+β2x2)0.5 = \frac{1}{1 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)}}

This implies:
1+e−(β0+β1x1+β2x2)=21 + e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)} = 2

Therefore:
e−(β0+β1x1+β2x2)=1e^{-(\beta_0 + \beta_1 x_1 + \beta_2 x_2)} = 1

Taking the natural logarithm of both sides:
−(β0+β1x1+β2x2)=ln⁡(1)-(\beta_0 + \beta_1 x_1 + \beta_2 x_2) = \ln(1)

Since ln⁡(1)=0\ln(1) = 0, we get:
β0+β1x1+β2x2=0\beta_0 + \beta_1 x_1 + \beta_2 x_2 = 0

This is the equation of the linear decision boundary.

Substitute the given parameter values: β0=−3\beta_0 = -3, β1=1\beta_1 = 1, and β2=−2\beta_2 = -2.

−3+x1+(−2)⋅x2=0-3 + x_1 + (-2) \cdot x_2 = 0

−3+x1−2x2=0-3 + x_1 - 2x_2 = 0

We need to express this in the form x2=f(x1)x_2 = f(x_1).

2x2=x1−32x_2 = x_1 - 3

x2=12x1−32x_2 = \frac{1}{2} x_1 - \frac{3}{2}

8

A 2D linear transformation TT is defined by the matrix M=(3113)M = \begin{pmatrix} 3 & 1 \\ 1 & 3 \end{pmatrix}. Consider a triangle with vertices A=(1,0)A = (1, 0), B=(0,1)B = (0, 1), and C=(1,1)C = (1, 1). This triangle is transformed by TT to a new triangle with vertices A′A', B′B', and C′C'. The area of the transformed triangle A′B′C′A'B'C' is then passed through a ReLU activation function, f(x)=max⁡(0,x)f(x) = \max(0, x). What is the final output value?

Advanced
Coordinate plane with graph of Span(v1), Span(v2); marked points v1 (2, 1), v2 (−1, 2)-3-2-1123-22xyv1v2Span(v1)Span(v2)

The area of the original triangle with vertices A=(1,0)A = (1, 0), B=(0,1)B = (0, 1), and C=(1,1)C = (1, 1) can be calculated. We can use the determinant formula for the area of a triangle given its vertices (x1,y1),(x2,y2),(x3,y3)(x_1, y_1), (x_2, y_2), (x_3, y_3): Area = 12∣x1(y2−y3)+x2(y3−y1)+x3(y1−y2)∣\frac{1}{2} |x_1(y_2 - y_3) + x_2(y_3 - y_1) + x_3(y_1 - y_2)|.
Plugging in the coordinates: Area = 12∣1(1−1)+0(1−0)+1(0−1)∣=12∣0+0−1∣=12\frac{1}{2} |1(1 - 1) + 0(1 - 0) + 1(0 - 1)| = \frac{1}{2} |0 + 0 - 1| = \frac{1}{2}.

A linear transformation represented by a matrix MM scales the area of a 2D shape by the absolute value of the determinant of the matrix MM. The determinant of M=(3113)M = \begin{pmatrix} 3 & 1 \\ 1 & 3 \end{pmatrix} is det⁡(M)=(3×3)−(1×1)=9−1=8\det(M) = (3 \times 3) - (1 \times 1) = 9 - 1 = 8. The absolute value is ∣8∣=8|8| = 8.
Therefore, the area of the transformed triangle A′B′C′A'B'C' is the original area multiplied by the determinant: Area(A′B′C′A'B'C') = 12×8=4\frac{1}{2} \times 8 = 4.
This area is then passed through a ReLU activation function f(x)=max⁡(0,x)f(x) = \max(0, x). Since the area is 4, which is positive, the ReLU function will return the value itself: f(4)=max⁡(0,4)=4f(4) = \max(0, 4) = 4.
Thus, the final output value is 4.

Final Answer: 44

9

The sigmoid activation function is σ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}. If σ(z0)=1.20\sigma(z_0) = 1.20, what is the value of the derivative σ′(z0)\sigma'(z_0)?

Advanced
Derivative sign chart showing intervals and function behavior: Derivative Sign & Monotonicity AnalysisDerivative Sign & Monotonicity Analysisxx < c₁c₁(c₁, c₂)c₂x > c₂f'(x)+0−0+f(x)↗Max↘Min↗

The derivative of sigmoid satisfies σ′(z)=σ(z)(1−σ(z))\sigma'(z) = \sigma(z)(1 - \sigma(z)). Substituting σ(z0)=1.20\sigma(z_0) = 1.20: σ′(z0)=(1.20)(1−1.20)=(1.20)(−0.20)=−0.2400\sigma'(z_0) = (1.20)(1 - 1.20) = (1.20)(-0.20) = -0.2400.

Final Answer: −0.2400-0.2400

10

A 3D dataset has covariance matrix eigenvalues λ1=62\lambda_1 = 62, λ2=24\lambda_2 = 24, and λ3=14\lambda_3 = 14. What percentage of total variance is explained by the first principal component PC1PC_1?

Intermediate
Five-Number Summary Distribution — Box plot summary: Min 12, Q1 24, Median 35, Q3 48, Max 64Five-Number Summary DistributionMinimum: 12Maximum: 64Q₁ = 24, Q₃ = 48Median (Q₂): 351224354864204060

Total variance is ∑λi=62+24+14=100\sum \lambda_i = 62 + 24 + 14 = 100. The proportion explained by PC1PC_1 is λ1∑λi=62100=62.0%\frac{\lambda_1}{\sum \lambda_i} = \frac{62}{100} = 62.0\%.

Final Answer: 62.0%62.0\%

11

Two document embeddings a=[5,10]T\mathbf{a} = [5, 10]^T and b=[10,5]T\mathbf{b} = [10, 5]^T are compared. If ∥a∥=∥b∥=125\|\mathbf{a}\| = \|\mathbf{b}\| = \sqrt{125}, calculate their exact cosine similarity.

Advanced
Coordinate plane with graph of y = f(x), y = g(x)-2-112-11234xyy = f(x)y = g(x)

Dot product a⋅b=(5)(10)+(10)(5)=100\mathbf{a} \cdot \mathbf{b} = (5)(10) + (10)(5) = 100. Product of norms ∥a∥∥b∥=125\|\mathbf{a}\| \|\mathbf{b}\| = 125. Cosine similarity = 100125=0.800\frac{100}{125} = 0.800.

Final Answer: 0.8000.800

12

Consider a dataset of nn data points, where each data point is a vector in RD\mathbb{R}^{D}. A non-linear dimensionality reduction technique maps these data points to a lower-dimensional space Rd\mathbb{R}^{d}. The mapping function for a single data point x∈RD\mathbf{x} \in \mathbb{R}^{D} is given by f(x)=ϕ(x)f(\mathbf{x}) = \phi(\mathbf{x}), where ϕ:RD→Rd\phi: \mathbb{R}^{D} \to \mathbb{R}^{d} is a function designed to preserve local neighborhood structures. Suppose the mapping ϕ\phi is defined by an explicit feature map ϕ(x)=[xTx,xTx,…,xTx]T\phi(\mathbf{x}) = [\mathbf{x}^T \mathbf{x}, \mathbf{x}^T \mathbf{x}, \dots, \mathbf{x}^T \mathbf{x}]^T where the vector x∈R10\mathbf{x} \in \mathbb{R}^{10} and dd is the dimension of the embedded space. If the goal is to embed these points into a space such that pairwise Euclidean distances are preserved as closely as possible under a specific distortion, and it is found that d=15d=15 yields optimal results for this mapping under a certain constraint, determine the effective rank of the feature map's image space.

Advanced
Scatter plot: Bivariate Data & Trend; x: Predictor (x); y: Response (y)Bivariate Data & Trend123345134689Predictor (x)Response (y)(1, 2.1)(2, 3.8)(3, 5.2)(4, 6.9)(5, 8.4)

The feature map is defined as ϕ(x)=[xTx,xTx,…,xTx]T\phi(\mathbf{x}) = [\mathbf{x}^T \mathbf{x}, \mathbf{x}^T \mathbf{x}, \dots, \mathbf{x}^T \mathbf{x}]^T, where x∈R10\mathbf{x} \in \mathbb{R}^{10}. The term xTx\mathbf{x}^T \mathbf{x} is the squared Euclidean norm of x\mathbf{x}, denoted as ∥x∥2\|\mathbf{x}\|^2. This is a scalar value. Thus, the mapping ϕ\phi produces a vector where each component is the same scalar value, ∥x∥2\|\mathbf{x}\|^2. Let k=∥x∥2k = \|\mathbf{x}\|^2. Then ϕ(x)=[k,k,…,k]T\phi(\mathbf{x}) = [k, k, \dots, k]^T in Rd\mathbb{R}^{d}. This means that the image of the mapping ϕ\phi is a subspace spanned by a single vector. For example, if d=15d=15, then ϕ(x)=[k,k,…,k]T\phi(\mathbf{x}) = [k, k, \dots, k]^T which can be written as k⋅[1,1,…,1]Tk \cdot [1, 1, \dots, 1]^T. The vector [1,1,…,1]T[1, 1, \dots, 1]^T forms a basis for the image space. Therefore, the dimension of the image space, which is equivalent to its rank, is 1, regardless of the value of dd (as long as d≥1d \ge 1). The problem states that d=15d=15, but the effective rank of the image of this specific feature map is always 1, as all output vectors lie on a single line passing through the origin.

13

A medical test for a rare disease has a 99\% accuracy rate in detecting the disease when it is present (True Positive Rate) and a 95\% accuracy rate in identifying individuals without the disease (True Negative Rate). If the prevalence of the disease in the population is 0.5\%, what is the probability that a person who tests positive actually has the disease?

Basic
Probability tree diagram: Two-Stage Probability TreeTwo-Stage Probability TreepAqB | AA ∩ B1-qB' | AA ∩ B'1-pA'rB | A'A' ∩ B1-rB' | A'A' ∩ B'

Let D be the event that a person has the disease, and P be the event that the person tests positive.
We are given:
P(P|D) = 0.99 (True Positive Rate)
P(not P|not D) = 0.95 (True Negative Rate), which means P(P|not D) = 1 - 0.95 = 0.05 (False Positive Rate)
P(D) = 0.005 (Prevalence of the disease)
From P(D), we know P(not D) = 1 - P(D) = 1 - 0.005 = 0.995.
We want to find P(D|P), the probability that a person has the disease given a positive test result.
Using Bayes' Theorem:
P(D|P) = [P(P|D) * P(D)] / P(P)
To find P(P), we use the law of total probability:
P(P) = P(P|D) * P(D) + P(P|not D) * P(not D)
P(P) = (0.99 * 0.005) + (0.05 * 0.995)
P(P) = 0.00495 + 0.04975
P(P) = 0.0547
Now, substitute this back into Bayes' Theorem:
P(D|P) = (0.99 * 0.005) / 0.0547
P(D|P) = 0.00495 / 0.0547
P(D|P) \approx 0.09049
Converting to a percentage, this is approximately 9.05\%, which rounds to 9.1\%.

Final Answer: Approximately 9.1\%

14

Consider a dataset with nn data points {x1,x2,…,xn}\{ \mathbf{x}_1, \mathbf{x}_2, \dots, \mathbf{x}_n \}, where each xi∈Rp\mathbf{x}_i \in \mathbb{R}^p. The sample covariance matrix is given by S=1n−1∑i=1n(xi−xˉ)(xi−xˉ)T\mathbf{S} = \frac{1}{n-1} \sum_{i=1}^n (\mathbf{x}_i - \bar{\mathbf{x}})(\mathbf{x}_i - \bar{\mathbf{x}})^T, where xˉ=1n∑i=1nxi\bar{\mathbf{x}} = \frac{1}{n} \sum_{i=1}^n \mathbf{x}_i is the sample mean. Suppose PCA is performed on this dataset, resulting in principal components defined by the eigenvectors of S\mathbf{S} and corresponding variances given by the eigenvalues. Let v1,v2,…,vp\mathbf{v}_1, \mathbf{v}_2, \dots, \mathbf{v}_p be the orthonormal eigenvectors of S\mathbf{S} with associated eigenvalues λ1≥λ2≥⋯≥λp\lambda_1 \ge \lambda_2 \ge \dots \ge \lambda_p. The first principal component captures the direction of maximum variance, λ1\lambda_1, and the second principal component captures the next largest variance, λ2\lambda_2, orthogonal to the first. If we decide to reduce the dimensionality from pp to kk by keeping only the first kk principal components, the proportion of the total variance retained is given by ∑i=1kλi∑i=1pλi\frac{\sum_{i=1}^k \lambda_i}{\sum_{i=1}^p \lambda_i}. Suppose for a particular dataset, the eigenvalues of the covariance matrix are {10.5,5.2,2.1,0.8,0.4}\{10.5, 5.2, 2.1, 0.8, 0.4 \}. If we aim to retain at least 90% of the total variance, what is the minimum number of principal components required?

Advanced
Normal distribution bell curve (mean 0, sd 1): Normal Distribution Model showing shaded probability regionNormal Distribution Model-3σ-2σ-1σ0+1σ+2σ+3σ

The total variance in the dataset is the sum of all eigenvalues: ∑i=1pλi=10.5+5.2+2.1+0.8+0.4=19.0\sum_{i=1}^p \lambda_i = 10.5 + 5.2 + 2.1 + 0.8 + 0.4 = 19.0.

We need to find the minimum kk such that ∑i=1kλi∑i=1pλi≥0.90\frac{\sum_{i=1}^k \lambda_i}{\sum_{i=1}^p \lambda_i} \ge 0.90.

Let's check for different values of kk:

For k=1k=1: The variance retained is 10.519.0≈0.553\frac{10.5}{19.0} \approx 0.553, which is less than 0.90.

For k=2k=2: The variance retained is 10.5+5.219.0=15.719.0≈0.826\frac{10.5 + 5.2}{19.0} = \frac{15.7}{19.0} \approx 0.826, which is less than 0.90.

For k=3k=3: The variance retained is 10.5+5.2+2.119.0=17.819.0≈0.937\frac{10.5 + 5.2 + 2.1}{19.0} = \frac{17.8}{19.0} \approx 0.937, which is greater than or equal to 0.90.

Therefore, a minimum of 3 principal components are required to retain at least 90% of the total variance.

15

Consider a simple linear regression model where the predicted value y^\hat{y} is given by y^=b0+b1x\hat{y} = b_0 + b_1 x. If we have two data points (x1,y1)=(2,5)(x_1, y_1) = (2, 5) and (x2,y2)=(4,9)(x_2, y_2) = (4, 9), and the Ordinary Least Squares (OLS) method yields the regression line y^=1+2x\hat{y} = 1 + 2x, what is the predicted value y^\hat{y} for x=3x = 3?

Basic

The problem provides a simple linear regression equation y^=b0+b1x\hat{y} = b_0 + b_1 x and specific values for the intercept b0=1b_0 = 1 and the slope b1=2b_1 = 2. We are asked to find the predicted value y^\hat{y} for a given value of xx. \nWe substitute x=3x = 3 into the regression equation: y^=1+2(3)\hat{y} = 1 + 2(3) y^=1+6\hat{y} = 1 + 6 y^=7\hat{y} = 7 \nTherefore, the predicted value y^\hat{y} for x=3x = 3 is 7. The data points (2,5)(2, 5) and (4,9)(4, 9) are consistent with this regression line: for x=2x=2, y^=1+2(2)=5\hat{y} = 1 + 2(2) = 5, and for x=4x=4, y^=1+2(4)=9\hat{y} = 1 + 2(4) = 9.

Final Answer: 77

16

A binary classification model uses a logistic sigmoid function σ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}. The decision boundary is defined by σ(z)=0.5\sigma(z) = 0.5, where z=w1x1+w0z = w_1 x_1 + w_0. For a dataset with two features x1x_1 and x2x_2, the model's linear component is z=2x1−x2+bz = 2x_1 - x_2 + b. If the classification boundary passes through the point (x1,x2)=(3,1)(x_1, x_2) = (3, 1), what is the value of the bias bb?

Intermediate

The logistic sigmoid function is σ(z)=11+e−z\sigma(z) = \frac{1}{1 + e^{-z}}. The decision boundary is where σ(z)=0.5\sigma(z) = 0.5. Setting σ(z)=0.5\sigma(z) = 0.5 gives 11+e−z=0.5\frac{1}{1 + e^{-z}} = 0.5, which implies 1=0.5(1+e−z)1 = 0.5(1 + e^{-z}), so 2=1+e−z2 = 1 + e^{-z}, and e−z=1e^{-z} = 1. This occurs when −z=0-z = 0, or z=0z = 0. Therefore, the decision boundary is defined by z=0z = 0.

The linear component of the model is given by z=w1x1+w2x2+bz = w_1 x_1 + w_2 x_2 + b. In this problem, z=2x1−x2+bz = 2x_1 - x_2 + b.

Since the decision boundary is z=0z = 0, we have 2x1−x2+b=02x_1 - x_2 + b = 0.

The classification boundary passes through the point (x1,x2)=(3,1)(x_1, x_2) = (3, 1). Substituting these values into the equation for the decision boundary:
2(3)−1+b=02(3) - 1 + b = 0
6−1+b=06 - 1 + b = 0
5+b=05 + b = 0
b=−5b = -5

Final Answer: b=−7b = -7

17

Consider the following quadratic loss function: L(w)=3w2−12w+10L(w) = 3w^2 - 12w + 10. What is the value of ww that minimizes this loss function?

Basic

To find the minimum of the quadratic loss function L(w)=3w2−12w+10L(w) = 3w^2 - 12w + 10, we can find the derivative with respect to ww and set it to zero. The derivative of L(w)L(w) with respect to ww is: dLdw=6w−12\frac{dL}{dw} = 6w - 12. Setting the derivative to zero to find the critical point: 6w−12=06w - 12 = 0 6w=126w = 12 w=126w = \frac{12}{6} w=2w = 2. The second derivative is d2Ldw2=6\frac{d^2L}{dw^2} = 6, which is positive, confirming that w=2w=2 corresponds to a minimum.

18

Consider a linear transformation represented by the matrix M=[2k13]M = \begin{bmatrix} 2 & k \\ 1 & 3 \end{bmatrix}. A vector v=[12]\mathbf{v} = \begin{bmatrix} 1 \\ 2 \end{bmatrix} is transformed by MM into v′=Mv=[87]\mathbf{v'} = M\mathbf{v} = \begin{bmatrix} 8 \\ 7 \end{bmatrix}. Determine the value of the unknown parameter kk.

Intermediate

The problem involves a matrix-vector multiplication. We are given the matrix M=[2k13]M = \begin{bmatrix} 2 & k \\ 1 & 3 \end{bmatrix} and the vectors v=[12]\mathbf{v} = \begin{bmatrix} 1 \\ 2 \end{bmatrix} and v′=[87]\mathbf{v'} = \begin{bmatrix} 8 \\ 7 \end{bmatrix}. The transformation is defined by v′=Mv\mathbf{v'} = M\mathbf{v}. Let's perform the matrix-vector multiplication:

[87]=[2k13][12]\begin{bmatrix} 8 \\ 7 \end{bmatrix} = \begin{bmatrix} 2 & k \\ 1 & 3 \end{bmatrix} \begin{bmatrix} 1 \\ 2 \end{bmatrix}

This expands to two equations:

1. 8=(2)(1)+(k)(2)8 = (2)(1) + (k)(2)
2. 7=(1)(1)+(3)(2)7 = (1)(1) + (3)(2)

Let's solve the first equation for kk:

8=2+2k8 = 2 + 2k

Subtract 2 from both sides:

6=2k6 = 2k

Divide by 2:

k=3k = 3

Now, let's verify this with the second equation. The second equation is 7=1+67 = 1 + 6, which simplifies to 7=77 = 7. This confirms our value of k=3k = 3 is consistent.

Therefore, the unknown parameter kk is 3.

19

A dataset consists of three independent observations X1,X2,X3X_1, X_2, X_3 drawn from a Poisson distribution with parameter λ\lambda. The observed values are x1=3,x2=5,x3=4x_1 = 3, x_2 = 5, x_3 = 4. We want to find the Maximum Likelihood Estimate (MLE) for λ\lambda. The log-likelihood function for a Poisson distribution is given by ℓ(λ)=∑i=1n(xilog⁡(λ)−log⁡(xi!)−λ)\ell(\lambda) = \sum_{i=1}^{n} \left( x_i \log(\lambda) - \log(x_i!) - \lambda \right).
Part 1: Derive the expression for the derivative of the log-likelihood function with respect to λ\lambda.
Part 2: Set the derivative to zero to find the MLE of λ\lambda.

Intermediate

The log-likelihood function for n=3n=3 observations is ℓ(λ)=(x1log⁡(λ)−log⁡(x1!)−λ)+(x2log⁡(λ)−log⁡(x2!)−λ)+(x3log⁡(λ)−log⁡(x3!)−λ)\ell(\lambda) = (x_1 \log(\lambda) - \log(x_1!) - \lambda) + (x_2 \log(\lambda) - \log(x_2!) - \lambda) + (x_3 \log(\lambda) - \log(x_3!) - \lambda).

Part 1: The derivative of the log-likelihood function with respect to λ\lambda is:
dℓdλ=∑i=13(xiλ−1)=(x1λ−1)+(x2λ−1)+(x3λ−1)\frac{d\ell}{d\lambda} = \sum_{i=1}^{3} \left( \frac{x_i}{\lambda} - 1 \right) = \left( \frac{x_1}{\lambda} - 1 \right) + \left( \frac{x_2}{\lambda} - 1 \right) + \left( \frac{x_3}{\lambda} - 1 \right).

Part 2: To find the MLE, we set the derivative to zero:
x1λ−1+x2λ−1+x3λ−1=0\frac{x_1}{\lambda} - 1 + \frac{x_2}{\lambda} - 1 + \frac{x_3}{\lambda} - 1 = 0
x1+x2+x3λ−3=0\frac{x_1 + x_2 + x_3}{\lambda} - 3 = 0
x1+x2+x3λ=3\frac{x_1 + x_2 + x_3}{\lambda} = 3
λ^=x1+x2+x33\hat{\lambda} = \frac{x_1 + x_2 + x_3}{3}.
Substituting the observed values x1=3,x2=5,x3=4x_1 = 3, x_2 = 5, x_3 = 4:
λ^=3+5+43=123=4\hat{\lambda} = \frac{3+5+4}{3} = \frac{12}{3} = 4.

Final Answer: λ^=3+5+43=4\hat{\lambda} = \frac{3+5+4}{3} = 4

20

A vector v\mathbf{v} is transformed into a new vector v′\mathbf{v}' by a linear transformation represented by the matrix M\mathbf{M}. We are given that v=(2 3)\mathbf{v} = \begin{pmatrix} 2 \ 3 \end{pmatrix} and v′=(7 11)\mathbf{v}' = \begin{pmatrix} 7 \ 11 \end{pmatrix}. The transformation matrix is of the form M=(a1 4b)\mathbf{M} = \begin{pmatrix} a & 1 \ 4 & b \end{pmatrix}. Determine the value of aa and bb.

Intermediate

The transformation is defined by v′=Mv\mathbf{v}' = \mathbf{M}\mathbf{v}. Substituting the given vectors and matrix form:

(7 11)=(a1 4b)(2 3)\begin{pmatrix} 7 \ 11 \end{pmatrix} = \begin{pmatrix} a & 1 \ 4 & b \end{pmatrix} \begin{pmatrix} 2 \ 3 \end{pmatrix}

Performing the matrix multiplication:

(7 11)=(2a+3 8+3b)\begin{pmatrix} 7 \ 11 \end{pmatrix} = \begin{pmatrix} 2a + 3 \ 8 + 3b \end{pmatrix}

Equating the corresponding components, we get a system of two linear equations:

1) 2a+3=72a + 3 = 7
2) 8+3b=118 + 3b = 11

Solving the first equation for aa:

2a=7−32a = 7 - 3
2a=42a = 4
a=2a = 2

Solving the second equation for bb:

3b=11−83b = 11 - 8
3b=33b = 3
b=1b = 1

Thus, a=2a = 2 and b=1b = 1.

Final Answer: a = 2, b = 1

21

Consider two events, A and B, with the following probabilities: P(A)=0.4P(A) = 0.4, P(B)=0.5P(B) = 0.5, and P(A∩B)=0.2P(A \cap B) = 0.2. What is the conditional probability of A given B, denoted as P(A∣B)P(A|B)?

Basic

The formula for conditional probability is P(A∣B)=P(A∩B)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}. Given P(A∩B)=0.2P(A \cap B) = 0.2 and P(B)=0.5P(B) = 0.5, we can substitute these values into the formula: P(A∣B)=0.20.5=0.4P(A|B) = \frac{0.2}{0.5} = 0.4. Therefore, the conditional probability of A given B is 0.4.

22

Consider a dataset with two features, X1X_1 and X2X_2. The covariance matrix for this dataset is given by: Σ=(105520)\Sigma = \begin{pmatrix} 10 & 5 \\ 5 & 20 \end{pmatrix} What is the variance of the first feature, X1X_1?

Basic

The covariance matrix Σ\Sigma for a dataset with two features X1X_1 and X2X_2 is structured as follows:
Σ=(Cov(X1,X1)Cov(X1,X2)Cov(X2,X1)Cov(X2,X2))\Sigma = \begin{pmatrix} Cov(X_1, X_1) & Cov(X_1, X_2) \\ Cov(X_2, X_1) & Cov(X_2, X_2) \end{pmatrix}
By definition, the variance of a random variable is the covariance of the variable with itself. Therefore, Var(X1)=Cov(X1,X1)Var(X_1) = Cov(X_1, X_1) and Var(X2)=Cov(X2,X2)Var(X_2) = Cov(X_2, X_2).

In the given covariance matrix:
Σ=(105520)\Sigma = \begin{pmatrix} 10 & 5 \\ 5 & 20 \end{pmatrix}
The element in the first row and first column represents Cov(X1,X1)Cov(X_1, X_1), which is the variance of X1X_1.

Thus, the variance of X1X_1 is 10. The covariance between X1X_1 and X2X_2 is 5, and the variance of X2X_2 is 20.

23

Consider a simple logistic regression model where the decision boundary is defined by the linear equation w1x1+w2x2+b=0w_1x_1 + w_2x_2 + b = 0. If the weights are w1=2w_1 = 2 and w2=3w_2 = 3, and the bias is b=−7b = -7, what is the equation of the decision boundary?

Basic

The decision boundary in a logistic regression model is defined by the equation where the log-odds are zero. This corresponds to a linear combination of the input features and weights, plus the bias, being equal to zero. Given the weights w1=2w_1 = 2 and w2=3w_2 = 3, and the bias b=−7b = -7, the equation of the decision boundary is w1x1+w2x2+b=0w_1x_1 + w_2x_2 + b = 0. Substituting the given values, we get 2x1+3x2+(−7)=02x_1 + 3x_2 + (-7) = 0, which simplifies to 2x1+3x2−7=02x_1 + 3x_2 - 7 = 0.

Final Answer: 2x1+3x2−7=02x_1 + 3x_2 - 7 = 0

24

Consider a simple quadratic loss function L(w)=(w2−4w+5)L(w) = (w^2 - 4w + 5). We want to find the minimum of this loss function using gradient descent. The gradient of the loss function with respect to ww is given by dLdw=2w−4\frac{dL}{dw} = 2w - 4. If we start at an initial weight w0=5w_0 = 5 and use a learning rate α=0.5\alpha = 0.5, what will be the value of the weight w1w_1 after the first update step, i.e., w1=w0−αdLdw(w0)w_1 = w_0 - \alpha \frac{dL}{dw}(w_0)?

Intermediate

The loss function is L(w)=w2−4w+5L(w) = w^2 - 4w + 5. The gradient is dLdw=2w−4\frac{dL}{dw} = 2w - 4. We are given an initial weight w0=5w_0 = 5 and a learning rate α=0.5\alpha = 0.5. The gradient at w0w_0 is dLdw(w0)=2(5)−4=10−4=6\frac{dL}{dw}(w_0) = 2(5) - 4 = 10 - 4 = 6. The update rule for gradient descent is w1=w0−αdLdw(w0)w_1 = w_0 - \alpha \frac{dL}{dw}(w_0). Substituting the values, we get w1=5−0.5×6=5−3=2w_1 = 5 - 0.5 \times 6 = 5 - 3 = 2.

Final Answer: 44

25

A linear transformation is defined by the matrix M=(2134)M = \begin{pmatrix} 2 & 1 \\ 3 & 4 \end{pmatrix}. If an input vector is v=(x1)v = \begin{pmatrix} x \\ 1 \end{pmatrix}, and the output vector after the transformation is w=(57)w = \begin{pmatrix} 5 \\ 7 \end{pmatrix}, what is the value of xx?

Basic

The linear transformation is given by w=Mvw = Mv. Substituting the given matrices and vectors, we have:
(37)=(2134)(x1)\begin{pmatrix} 3 \\ 7 \end{pmatrix} = \begin{pmatrix} 2 & 1 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} x \\ 1 \end{pmatrix}
Performing the matrix multiplication on the right side gives:
(37)=(2x+1(1)3x+4(1))=(2x+13x+4)\begin{pmatrix} 3 \\ 7 \end{pmatrix} = \begin{pmatrix} 2x + 1(1) \\ 3x + 4(1) \end{pmatrix} = \begin{pmatrix} 2x + 1 \\ 3x + 4 \end{pmatrix}
Equating the corresponding components of the vectors, we get two equations:
1. 3=2x+13 = 2x + 1
2. 7=3x+47 = 3x + 4

Solving the first equation for xx:
3−1=2x3 - 1 = 2x
2=2x2 = 2x
x=22x = \frac{2}{2}
x=1x = 1

Solving the second equation for xx:
7−4=3x7 - 4 = 3x
3=3x3 = 3x
x=33x = \frac{3}{3}
x=1x = 1

Both equations yield x=1x=1. Therefore, the value of xx is 1.

26

A dataset consists of n=100n=100 independent and identically distributed (i.i.d.) observations x1,x2,…,x100x_1, x_2, \dots, x_{100}. These observations are drawn from a Bernoulli distribution with parameter pp. The probability mass function (PMF) of a Bernoulli distribution is given by P(X=x;p)=px(1−p)1−xP(X=x; p) = p^x (1-p)^{1-x} for x∈{0,1}x \in \{0, 1\}. The likelihood function L(p)L(p) for this dataset is the product of the PMFs of the individual observations. If we observe k=60k=60 successes (i.e., xi=1x_i = 1) and n−k=40n-k=40 failures (i.e., xi=0x_i = 0), what is the likelihood function L(p)L(p) for pp?

Basic

The likelihood function L(p)L(p) is the product of the probabilities of observing each data point given the parameter pp. For i.i.d. Bernoulli trials, L(p)=∏i=1nP(X=xi;p)L(p) = \prod_{i=1}^{n} P(X=x_i; p). Given n=100n=100 observations, with k=60k=60 successes (where xi=1x_i=1) and n−k=40n-k=40 failures (where xi=0x_i=0), the likelihood function can be written as:

L(p)=(∏i:xi=1p1(1−p)1−1)×(∏i:xi=0p0(1−p)1−0)L(p) = \left( \prod_{i: x_i=1} p^1 (1-p)^{1-1} \right) \times \left( \prod_{i: x_i=0} p^0 (1-p)^{1-0} \right)

L(p)=(∏i:xi=1p)×(∏i:xi=0(1−p))L(p) = \left( \prod_{i: x_i=1} p \right) \times \left( \prod_{i: x_i=0} (1-p) \right)

Since there are k=60k=60 terms of pp and n−k=40n-k=40 terms of (1−p)(1-p), the likelihood function simplifies to:

L(p)=p60(1−p)40L(p) = p^{60} (1-p)^{40}

Final Answer: p60(1−p)40p^{60} (1-p)^{40}

27

Consider two vectors, u=[34]\mathbf{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} and v=[1−2]\mathbf{v} = \begin{bmatrix} 1 \\ -2 \end{bmatrix}. What is the vector representing 2u−v2\mathbf{u} - \mathbf{v}?

Basic

To find the vector 2u−v2\mathbf{u} - \mathbf{v}, we first compute 2u2\mathbf{u} and then subtract v\mathbf{v} from the result.

2u=2×[34]=[2×32×4]=[68]2\mathbf{u} = 2 \times \begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 2 \times 3 \\ 2 \times 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix}.

Now, we subtract v\mathbf{v} from 2u2\mathbf{u}:

2u−v=[68]−[1−2]=[6−18−(−2)]=[58+2]=[510]2\mathbf{u} - \mathbf{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ -2 \end{bmatrix} = \begin{bmatrix} 6 - 1 \\ 8 - (-2) \end{bmatrix} = \begin{bmatrix} 5 \\ 8 + 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 10 \end{bmatrix}.

Therefore, the resulting vector is [510]\begin{bmatrix} 5 \\ 10 \end{bmatrix}.

28

Consider a dataset of observations {xi}i=1n\{x_i\}_{i=1}^n where each xix_i is a 2-dimensional vector. The sample covariance matrix for this dataset is given by:
S=(4−2−21)S = \begin{pmatrix} 4 & -2 \\ -2 & 1 \end{pmatrix}
Principal Component Analysis (PCA) is applied to this dataset. The first principal component corresponds to the direction with the largest variance. Let the direction vector of the first principal component be v1=(ab)\mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix}. The variance explained by this principal component is given by the corresponding eigenvalue λ1\lambda_1.
If v1\mathbf{v}_1 is a unit vector, what is the value of a2+b2a^2+b^2?

Intermediate

The first principal component direction vector v1\mathbf{v}_1 is an eigenvector of the covariance matrix SS. The variance explained by this component is the corresponding eigenvalue λ1\lambda_1. The problem states that v1=(ab)\mathbf{v}_1 = \begin{pmatrix} a \\ b \end{pmatrix} is a unit vector. By definition, a unit vector has a magnitude of 1. The squared magnitude of a vector (ab)\begin{pmatrix} a \\ b \end{pmatrix} is a2+b2a^2 + b^2. Therefore, if v1\mathbf{v}_1 is a unit vector, its squared magnitude must be 1, which means a2+b2=1a^2 + b^2 = 1. The specific values of aa and bb and the eigenvalues of SS are not needed to answer this question, as it directly asks for the property of a unit vector.

29

Consider the quadratic loss function L(w)=w2−4w+3L(w) = w^2 - 4w + 3. Find the value of ww where the function reaches its minimum.

Basic
Coordinate plane with graph of w*w − 4w + 31234-1123xy

The given loss function is a quadratic function L(w)=w2−4w+3L(w) = w^2 - 4w + 3. This represents a parabola opening upwards. The minimum value of a quadratic function of the form aw2+bw+caw^2 + bw + c occurs at w=−b2aw = -\frac{b}{2a}. In this case, a=1a = 1 and b=−4b = -4. Therefore, the minimum occurs at w=−−42(1)=42=2w = -\frac{-4}{2(1)} = \frac{4}{2} = 2. Alternatively, we can find the minimum by taking the derivative and setting it to zero: L′(w)=2w−4L'(w) = 2w - 4. Setting L′(w)=0L'(w) = 0 gives 2w−4=02w - 4 = 0, which implies 2w=42w = 4, so w=2w = 2.

30

A simple linear regression model has been fitted to a dataset. The model equation is given by y^=ax+b\hat{y} = ax + b. The regression line passes through the points (2,10)(2, 10) and (5,22)(5, 22) in the feature-target space. Determine the value of the intercept bb.

Intermediate
Coordinate plane with graph of 4x + 2; marked points (2, 10), (5, 22)123455101520xy

The problem states that the linear regression line y^=ax+b\hat{y} = ax + b passes through two points: (x1,y1)=(2,10)(x_1, y_1) = (2, 10) and (x2,y2)=(5,22)(x_2, y_2) = (5, 22).

We can use these two points to form a system of linear equations to solve for the unknown parameters aa (the slope) and bb (the intercept).

Substituting the first point (2,10)(2, 10) into the equation y^=ax+b\hat{y} = ax + b gives:
10=a(2)+b10 = a(2) + b (Equation 1)

Substituting the second point (5,22)(5, 22) into the equation y^=ax+b\hat{y} = ax + b gives:
22=a(5)+b22 = a(5) + b (Equation 2)

To find the slope aa, we can subtract Equation 1 from Equation 2:
(22−10)=(5a−2a)+(b−b)(22 - 10) = (5a - 2a) + (b - b)
12=3a12 = 3a
a=123=4a = \frac{12}{3} = 4

Now that we have the value of aa, we can substitute it back into either Equation 1 or Equation 2 to solve for bb. Let's use Equation 1:
10=4(2)+b10 = 4(2) + b
10=8+b10 = 8 + b
b=10−8b = 10 - 8
b=2b = 2

Let's verify with Equation 2:
22=4(5)+b22 = 4(5) + b
22=20+b22 = 20 + b
b=22−20b = 22 - 20
b=2b = 2

Both equations yield b=2b = 2. Therefore, the intercept bb is 2.

Common algebraic traps include incorrectly calculating the slope or making sign errors when substituting values back into the equations. For instance, if one incorrectly calculated the slope as 312\frac{3}{12} or made a sign error in 10−810 - 8, they might arrive at an incorrect intercept.

31

Consider a 2D dataset represented by the points A=(1,2)A = (1, 2), B=(4,2)B = (4, 2), and C=(2,5)C = (2, 5). If this dataset undergoes a linear transformation represented by the matrix M=(2001)M = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix}, what are the coordinates of the transformed points A′A', B′B', and C′C'?

Basic
Coordinate transformation grid showing object and transformed image-448-6-4-2246ABCA'B'C'

The transformation of a point x\mathbf{x} by a matrix MM is given by MxM \mathbf{x}. We apply the matrix M=(2001)M = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} to each point:

For point A=(1,2)A = (1, 2), the transformed point A′A' is:
(2001)(12)=(2×1+0×20×1+1×2)=(22)\begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} 1 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 \times 1 + 0 \times 2 \\ 0 \times 1 + 1 \times 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 2 \end{pmatrix} So, A′=(2,2)A' = (2, 2).

For point B=(4,2)B = (4, 2), the transformed point B′B' is:
(2001)(42)=(22)\begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} 4 \\ 2 \end{pmatrix} = \begin{pmatrix} 2 \\ 2 \end{pmatrix} So, B′=(8,2)B' = (8, 2).

For point C=(2,5)C = (2, 5), the transformed point C′C' is:
(2001)(25)=(2×2+0×50×2+1×5)=(45)\begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix} 2 \\ 5 \end{pmatrix} = \begin{pmatrix} 2 \times 2 + 0 \times 5 \\ 0 \times 2 + 1 \times 5 \end{pmatrix} = \begin{pmatrix} 4 \\ 5 \end{pmatrix} So, C′=(4,5)C' = (4, 5).

Therefore, the transformed points are A′=(2,2)A' = (2, 2), B′=(8,2)B' = (8, 2), and C′=(4,5)C' = (4, 5).

32

Consider a discrete random variable XX with the following probability mass function (PMF): P(X=x)=x10P(X=x) = \frac{x}{10} for x∈{1,2,3,4}x \in \{1, 2, 3, 4\}. What is the value of P(X≤2)P(X \le 2)?

Basic

The probability mass function is given by P(X=x)=x10P(X=x) = \frac{x}{10} for x∈{1,2,3,4}x \in \{1, 2, 3, 4\}. We need to find P(X≤2)P(X \le 2). This is the sum of probabilities for X=1X=1 and X=2X=2. P(X≤2)=P(X=1)+P(X=2)P(X \le 2) = P(X=1) + P(X=2). P(X=1)=110P(X=1) = \frac{1}{10} and P(X=2)=210P(X=2) = \frac{2}{10}. Therefore, P(X≤2)=110+210=310P(X \le 2) = \frac{1}{10} + \frac{2}{10} = \frac{3}{10}.

33

Consider a dataset where the number of defective items produced by a machine per hour, YY, follows a Poisson distribution with a rate parameter λ=3\lambda = 3. The probability mass function (PMF) for a Poisson distribution is given by P(Y=k)=λke−λk!P(Y=k) = \frac{\lambda^k e^{-\lambda}}{k!} for k=0,1,2,…k = 0, 1, 2, \dots. What is the value of λ\lambda in this scenario?

Basic

The problem statement explicitly defines that the number of defective items, YY, follows a Poisson distribution with a rate parameter λ=3\lambda = 3. The rate parameter λ\lambda is a direct characteristic of the Poisson distribution that determines its mean and variance. Therefore, the value of λ\lambda is directly given as 3.

34

Consider a simple linear regression model where a dependent variable yy is predicted from an independent variable xx. The model is given by the equation y=β0+β1x+ϵy = \beta_0 + \beta_1 x + \epsilon, where ϵ\epsilon is the error term. Suppose we have estimated the regression line to be y^=3+2x\hat{y} = 3 + 2x. If we observe an independent variable value of x=4x=4, what is the predicted value y^\hat{y} for the dependent variable?

Basic

The problem asks for the predicted value y^\hat{y} given an independent variable value x=4x=4 and a linear regression equation y^=3+2x\hat{y} = 3 + 2x. We substitute the value of xx into the equation:

y^=3+2(4)\hat{y} = 3 + 2(4)
y^=3+8\hat{y} = 3 + 8
y^=11\hat{y} = 11

Therefore, the predicted value for the dependent variable is 11. Common errors might involve incorrectly multiplying 2 by 4 or incorrectly adding 3 to 8.

35

A centered feature matrix X\mathbf{X} has shape N×22N \times 22. What is the size and symmetry property of the sample covariance matrix Σ=1N−1XTX\mathbf{\Sigma} = \frac{1}{N-1}\mathbf{X}^T\mathbf{X}?

Advanced

Since X\mathbf{X} has 2222 columns, XT\mathbf{X}^T is 22×N22 \times N and XTX\mathbf{X}^T\mathbf{X} is 22×2222 \times 22. Furthermore, (XTX)T=XT(XT)T=XTX(\mathbf{X}^T\mathbf{X})^T = \mathbf{X}^T(\mathbf{X}^T)^T = \mathbf{X}^T\mathbf{X}, proving it is always symmetric.

36

Consider a linear layer with a weight matrix WW and an input vector x\mathbf{x}. If W=(1234)W = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} and x=(56)\mathbf{x} = \begin{pmatrix} 5 \\ 6 \end{pmatrix}, compute the output vector y=Wx\mathbf{y} = W\mathbf{x}.

Basic

The output vector y\mathbf{y} is computed by multiplying the weight matrix WW by the input vector x\mathbf{x}. This is a standard matrix-vector multiplication. \\ \\ y=Wx=(1234)(56)\mathbf{y} = W\mathbf{x} = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \begin{pmatrix} 5 \\ 6 \end{pmatrix}\\\ \\ To compute the first element of y\mathbf{y}, we take the dot product of the first row of WW with x\mathbf{x}: (1)(5)+(2)(6)=5+12=17(1)(5) + (2)(6) = 5 + 12 = 17.\\ \\ To compute the second element of y\mathbf{y}, we take the dot product of the second row of WW with x\mathbf{x}: (3)(5)+(4)(6)=15+24=39(3)(5) + (4)(6) = 15 + 24 = 39.\\ \\ Therefore, the output vector is y=(1739)\mathbf{y} = \begin{pmatrix} 17 \\ 39 \end{pmatrix}.

37

Consider two vectors, u=(3−2)\mathbf{u} = \begin{pmatrix} 3 \\ -2 \end{pmatrix} and v=(−15)\mathbf{v} = \begin{pmatrix} -1 \\ 5 \end{pmatrix}. What is the resultant vector w=u+v\mathbf{w} = \mathbf{u} + \mathbf{v}?

Basic

To find the resultant vector w=u+v\mathbf{w} = \mathbf{u} + \mathbf{v}, we add the corresponding components of the two vectors. w=(3−2)+(−15)=(3+(−1)−2+5)=(23)\mathbf{w} = \begin{pmatrix} 3 \\ -2 \end{pmatrix} + \begin{pmatrix} -1 \\ 5 \end{pmatrix} = \begin{pmatrix} 3 + (-1) \\ -2 + 5 \end{pmatrix} = \begin{pmatrix} 2 \\ 3 \end{pmatrix}.

38

In training a language model token predictor, a binary token occurs k=15k = 15 times across n=50n = 50 independent trials. What is the Maximum Likelihood Estimate p^MLE\hat{p}_{\text{MLE}} of the token probability?

Advanced

For a Bernoulli likelihood L(p)=pk(1−p)n−kL(p) = p^k (1-p)^{n-k}, the log-likelihood is ln⁡L=kln⁡p+(n−k)ln⁡(1−p)\ln L = k\ln p + (n-k)\ln(1-p). Setting derivative to zero: kp−n−k1−p=0  ⟹  p^=kn=1550=0.300\frac{k}{p} - \frac{n-k}{1-p} = 0 \implies \hat{p} = \frac{k}{n} = \frac{15}{50} = 0.300.

39

Consider the following quadratic loss function for a regression problem: L(y,y^)=(y−y^)2L(y, \hat{y}) = (y - \hat{y})^2. If the predicted value y^=5\hat{y} = 5 and the true value y=3y = 3, what is the value of the loss function?

Basic

The quadratic loss function is defined as L(y,y^)=(y−y^)2L(y, \hat{y}) = (y - \hat{y})^2. Given the true value y=3y = 3 and the predicted value y^=5\hat{y} = 5, we substitute these values into the loss function:

L(3,5)=(3−5)2L(3, 5) = (3 - 5)^2

L(3,5)=(−2)2L(3, 5) = (-2)^2

L(3,5)=4L(3, 5) = 4

Therefore, the value of the loss function is 4.

40

Consider a 2D data point v=[3−4]\mathbf{v} = \begin{bmatrix} 3 \\ -4 \end{bmatrix}. What is the squared Euclidean norm (or squared magnitude) of this vector?

Basic

The squared Euclidean norm of a vector v=[v1v2]\mathbf{v} = \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} is given by ∥v∥2=v12+v22\|\mathbf{v}\|^2 = v_1^2 + v_2^2. For the given vector v=[3−4]\mathbf{v} = \begin{bmatrix} 3 \\ -4 \end{bmatrix}, the squared Euclidean norm is (3)2+(−4)2=9+16=25(3)^2 + (-4)^2 = 9 + 16 = 25.

41

A vector v\mathbf{v} is represented in a 2D space. If the components of the vector are vx=−3v_x = -3 and vy=4v_y = 4, what is the Euclidean (L2L_2) norm of this vector?

Basic

The Euclidean (L2L_2) norm of a vector v=[vx,vy]T\mathbf{v} = [v_x, v_y]^T is calculated as ∥v∥2=vx2+vy2\|\mathbf{v}\|_2 = \sqrt{v_x^2 + v_y^2}. For the given vector v\mathbf{v} with components vx=−3v_x = -3 and vy=4v_y = 4, the norm is: ∥v∥2=(−3)2+(4)2=9+16=25=5\|\mathbf{v}\|_2 = \sqrt{(-3)^2 + (4)^2} = \sqrt{9 + 16} = \sqrt{25} = 5.

42

A machine learning diagnostic test has sensitivity P(Positive∣Defect)=0.90P(\text{Positive} | \text{Defect}) = 0.90. If the defect rate in production is P(Defect)=0.25P(\text{Defect}) = 0.25, find the joint probability of a defect and a positive test result P(Defect∩Positive)P(\text{Defect} \cap \text{Positive}).

Intermediate

By the multiplication rule of conditional probability: P(Defect∩Positive)=P(Defect)×P(Positive∣Defect)=0.25×0.90=0.2250P(\text{Defect} \cap \text{Positive}) = P(\text{Defect}) \times P(\text{Positive} | \text{Defect}) = 0.25 \times 0.90 = 0.2250.

43

A 2D loss surface is defined as L(w1,w2)=2w12+3w22L(w_1, w_2) = 2w_1^2 + 3w_2^2. Find the gradient vector ∇L\nabla L at the point (w1,w2)=(2,−1)(w_1, w_2) = (2, -1).

Advanced

Compute partial derivatives: ∂L∂w1=2(2)w1=4(2)=8\frac{\partial L}{\partial w_1} = 2(2)w_1 = 4(2) = 8; ∂L∂w2=2(3)w2=6(−1)=−6\frac{\partial L}{\partial w_2} = 2(3)w_2 = 6(-1) = -6. Therefore, ∇L=[8,−6]T\nabla L = [8, -6]^T.

44

A medical diagnostic test for a rare disease is designed to be highly sensitive and specific. The disease affects 11 in every 10001000 individuals in the population. The test has a sensitivity of 9999\% (meaning it correctly identifies 9999\% of individuals who have the disease) and a specificity of 9595\% (meaning it correctly identifies 9595\% of individuals who do not have the disease). If a randomly selected individual from the population tests positive, what is the probability that they actually have the disease?

Advanced

Let D be the event that an individual has the disease, and P be the event that the individual tests positive.
We are given the following probabilities:
- Prior probability of having the disease: P(D)=11000=0.001P(D) = \frac{1}{1000} = 0.001
- Prior probability of not having the disease: P(Dc)=1−P(D)=1−0.001=0.999P(D^c) = 1 - P(D) = 1 - 0.001 = 0.999
- Sensitivity (true positive rate): P(P∣D)=0.99P(P|D) = 0.99
- Specificity (true negative rate): P(Pc∣Dc)=0.95P(P^c|D^c) = 0.95
From specificity, we can derive the false positive rate: P(P∣Dc)=1−P(Pc∣Dc)=1−0.95=0.05P(P|D^c) = 1 - P(P^c|D^c) = 1 - 0.95 = 0.05.

We want to find the probability that an individual actually has the disease given a positive test result, which is P(D∣P)P(D|P). We can use Bayes' Theorem:

P(D∣P)=P(P∣D)P(D)P(P)P(D|P) = \frac{P(P|D) P(D)}{P(P)}

To find P(P)P(P), the overall probability of testing positive, we can use the law of total probability:

P(P)=P(P∣D)P(D)+P(P∣Dc)P(Dc)P(P) = P(P|D) P(D) + P(P|D^c) P(D^c)

Substitute the given values:

P(P)=(0.99)(0.001)+(0.05)(0.999)P(P) = (0.99)(0.001) + (0.05)(0.999)
P(P)=0.00099+0.04995P(P) = 0.00099 + 0.04995
P(P)=0.05094P(P) = 0.05094

Now, substitute P(P)P(P) back into Bayes' Theorem:

P(D∣P)=(0.99)(0.001)0.05094P(D|P) = \frac{(0.99)(0.001)}{0.05094}
P(D∣P)=0.000990.05094P(D|P) = \frac{0.00099}{0.05094}
P(D∣P)≈0.0194346P(D|P) \approx 0.0194346

Therefore, the probability that a person who tests positive actually has the disease is approximately 0.01940.0194, which is closest to 0.0190.019.

45

Compute the Manhattan (L1L_1) norm and Euclidean (L2L_2) norm of the word vector w=[10,−15]T\mathbf{w} = [10, -15]^T.

Intermediate

L1L_1 norm is the sum of absolute values: ∣10∣+∣−15∣=25|10| + |-15| = 25. L2L_2 norm is the square root of sum of squares: (10)2+(−15)2=100+225=325\sqrt{(10)^2 + (-15)^2} = \sqrt{100 + 225} = \sqrt{325}.

46

In a multiple linear regression model, the Sum of Squared Errors is SSE=20\text{SSE} = 20 and the Total Sum of Squares is SST=100\text{SST} = 100. What is the coefficient of determination R2R^2?

Intermediate

The coefficient of determination measures the proportion of variance explained: R2=1−SSESST=1−20100=1−0.20=0.80R^2 = 1 - \frac{\text{SSE}}{\text{SST}} = 1 - \frac{20}{100} = 1 - 0.20 = 0.80.

Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.

47

In evaluating a binary classifier, the confusion matrix shows TP=70TP = 70, TN=40TN = 40, FP=10FP = 10, and FN=10FN = 10. Compute the overall classification accuracy.

Basic

Accuracy is the ratio of correct predictions to total samples: Accuracy=TP+TNTP+TN+FP+FN=70+40130=110130=84.6%\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN} = \frac{70 + 40}{130} = \frac{110}{130} = 84.6\%.

Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.

48

A fully-connected dense layer maps an input x∈R50\mathbf{x} \in \mathbb{R}^{50} to y∈R25\mathbf{y} \in \mathbb{R}^{25} using y=Wx+b\mathbf{y} = \mathbf{W}\mathbf{x} + \mathbf{b}. How many total learnable parameters are in this layer?

Basic

The weight matrix W\mathbf{W} has shape 25×5025 \times 50, giving 12501250 weights. The bias vector b\mathbf{b} has 2525 parameters. Total = 1250+25=12751250 + 25 = 1275.

Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.

49

A logistic regression model produces a class probability p=P(y=1∣x)=0.30p = P(y=1|\mathbf{x}) = 0.30. Compute the corresponding log-odds (logit) ln⁡(p1−p)\ln\left(\frac{p}{1-p}\right).

Advanced

Odds are p1−p=0.300.70=0.4286\frac{p}{1-p} = \frac{0.30}{0.70} = 0.4286. Taking natural logarithm: ln⁡(0.4286)=−0.847\ln(0.4286) = -0.847.

Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.

50

Evaluate the output of the standard ReLU activation function f(z)=max⁡(0,z)f(z) = \max(0, z) for inputs z1=−4z_1 = -4 and z2=6z_2 = 6.

Intermediate

By definition of the Rectified Linear Unit: ReLU(z)=z\text{ReLU}(z) = z if z>0z \gt 0, and 00 if z≤0z \le 0. Thus f(−4)=0f(-4) = 0 and f(6)=6f(6) = 6.

Key Mathematical Principle & Verification: In exam revision, always verify that the final result satisfies all domain restrictions, boundary conditions, and the original governing equation by direct substitution into the prompt.

AI-assisted, human-reviewed: Questions and walkthroughs are developed with AI assistance and reviewed by senior educators. Report an error here ↗

Generate an authentic assessment covering vector embeddings, neural feedforward calculations, gradient descent optimization, and classification metrics.

Full official exam paper

Comprehensive 100-mark assessment covering the mathematical foundations required for modern Machine Learning, Deep Learning, and Data Science.

AI-assisted, human-reviewed: Questions and walkthroughs are developed with AI assistance and reviewed by senior educators. Report an error here ↗
↓

Downloads

Study Math for AI & Data Science offline. Download comprehensive cheat sheets on neural layer matrix operations, gradient updates, Bayes rules, and dimensionality reduction.

PDF · ready now

Math for AI & Data Science Handbook

Eight foundational chapters covering high-dimensional geometry, gradient descent, loss landscapes, and probabilistic modeling.

DOCX · on request

Native Word packet

Editable .docx problem sets with complete formulas and step-by-step mathematical proofs.

Worksheet Library

Curated collection of applied AI math drills, vector similarity exercises, and loss optimization challenges.

Loading worksheet library…

Mock Exam

--:--