S30 Logo
S30 AI Labwww.thes30.com
Back
#8

Math Lab (Linear Algebra + Probability)

Easy📐 Math for MLW2 D5

Math Lab (Linear Algebra + Probability)

Consolidate Week 2 with derivations + short computational checks.

Students can derive key results, verify with small code experiments, and communicate clearly under interview constraints.

Progress — 0/6 tasks

1Tasks
2Projection Matrix Properties
3PSD Matrix Check
4Least Squares Derivation
5Bayes + Base Rate
6PCA Link

Interview Angles

  • Where does PSD show up in ML (covariance, kernels)?
  • How does PCA relate to embeddings and compression?

FAANG Gotchas

  • Avoid matrix inverse; use solve/lstsq.

Asked At

GoogleSquareGitHub
Python 3 — Notebook
0/6 solvedSubstack Notes
1
Dataset & Setup

Math Lab — FAANG-Level Mixed Problems

This lab is a problem set + mini-verification notebook covering projection matrices, PSD checks, least squares, Bayes intuition, and PCA links.

Loading editor...
Solution
1

Projection Matrix Properties

2
Construct projection and verify properties
2

Problem 1 — Projection Matrix Properties

Let P be a projection matrix onto a subspace.

  1. Show that P^2 = P (idempotent).
  2. For orthogonal projection, show P = P^T.

Task 1.1

Construct projection onto span(u) and verify both properties.

Explain: What does idempotent mean geometrically for projections?
Loading editor...
Solution
2

PSD Matrix Check

3
Verify X^T X is PSD
1

Problem 2 — PSD Matrix Check

Show that for any matrix X, A = X^T X is positive semidefinite (PSD).

Task 2.1

Sample random X, build A, and verify v^T A v >= 0 for many random vectors v.

Explain: Why does v^T X^T X v equal ||Xv||^2?
Loading editor...
Solution
3

Least Squares Derivation

4
Normal equation vs lstsq
1

Problem 3 — Least Squares Derivation

Derive the normal equations for minimizing ||Xw - y||^2.

Task 3.1

Compare w_hat from solve vs np.linalg.lstsq.

Explain: Why is solve/lstsq preferred over explicit matrix inverse?
Loading editor...
Solution
4

Bayes + Base Rate

5
Analytic vs simulated P(D|+)
1

Problem 4 — Bayes + Base Rate (Derivation)

Re-derive P(D|+) for the disease test scenario and explain the base-rate fallacy.

Task 4.1

Compute analytic posterior and verify with simulation.

Explain: Why can P(D|+) still be low when test sensitivity is high?
Loading editor...
Solution
5

PCA Link

6
Covariance eigenvectors vs SVD directions
1

Problem 5 — PCA Link

Explain why PCA components are eigenvectors of the covariance matrix.

Task 5.1

Compute covariance eigenvectors and compare with SVD directions.

Explain: Why do right singular vectors align with covariance eigenvectors?
Loading editor...
Solution

Need help? Share feedback