Chapter 2: Mathematics for AI
Why is Math important in AI?
Because AI models are built using mathematical concepts to learn from data, make predictions, and improve over time.
🔢 1. Linear Algebra (💡 Used in all AI models)
Linear Algebra is the foundation of machine learning, especially in neural networks and deep learning.
Key Concepts:
Concept | Explanation | Example |
---|---|---|
Scalars | Single number | 5 |
Vectors | 1D array of numbers | [3, 2, -1] |
Matrices | 2D array of numbers | [[1,2],[3,4]] |
Tensors | n-dimensional arrays | Used in TensorFlow |
Operations:
-
Matrix Multiplication
-
Dot Product
-
Transpose
-
Inverse Matrix
📌 Used in: Image processing, word embeddings, transformations in neural networks.
🎲 2. Probability & Statistics (💡 Used in decision-making)
Used to measure uncertainty and make predictions based on data.
Key Topics:
Concept | Explanation |
---|---|
Probability | Likelihood of an event |
Random Variables | Variables with random outcomes |
Bayes' Theorem | Probability of cause given an effect |
Mean / Median / Mode | Central tendency |
Variance / Standard Deviation | Spread of data |
Distributions | Normal (Gaussian), Binomial, Poisson |
🔧 Bayes' Theorem:
Used in: Spam filtering, medical diagnosis, NLP tasks.
📈 3. Calculus (💡 Powers learning in neural networks)
Helps machines learn by adjusting weights to minimize error (gradient descent).
Key Topics:
Concept | Use in AI |
---|---|
Derivatives | Measure change of a function |
Partial Derivatives | For multivariable functions |
Gradients | Direction of steepest increase/decrease |
Chain Rule | Used in backpropagation in neural nets |
Example:
-
Backpropagation in deep learning uses calculus to update weights.
-
Loss function minimized using Gradient Descent.
📊 4. Discrete Mathematics (💡 Used in logic, search, and graphs)
AI problems are often modeled as search problems and decision-making systems.
Key Topics:
Concept | Explanation |
---|---|
Logic | AND, OR, NOT, IF-THEN rules |
Sets | Group of elements |
Functions | Input-output mappings |
Graph Theory | Nodes and edges – used in NLP, path-finding |
Combinatorics | Counting and arrangements – used in game AI |
📌 Examples:
-
Graph algorithms like Dijkstra’s (shortest path) used in Google Maps.
-
Boolean Logic used in rule-based AI systems.
🧠 AI Math in Action
Math Concept | Real AI Use |
---|---|
Linear Algebra | Neural Networks, Word Embeddings |
Probability | Spam Detection, Predictions |
Calculus | Deep Learning Optimization |
Discrete Math | Logic-based AI, Game Playing |
📝 Summary
Topic | Role in AI |
---|---|
Linear Algebra | Handles structured data and models |
Probability | Models uncertainty and decision-making |
Calculus | Enables learning in deep learning |
Discrete Math | Useful for logical reasoning and graph structures |
✅ Mini-Assignment:
-
Write down the dot product of two vectors: [1, 2] and [3, 4]
-
Try solving a Bayes’ Theorem problem
-
Use NumPy in Python to create a 2x2 matrix and multiply it