"Do I need to be good at maths to work in AI?" The honest answer: you need to be comfortable with a handful of ideas, not a whole degree. Using libraries, you can build many things with little formal maths, but understanding the basics helps you debug, choose methods and read documentation with confidence. Here is the essential toolkit and how each part appears in AI.
1. Linear algebra: the language of data
Almost everything in machine learning is represented as numbers in arrays.
Vectors
A vector is a list of numbers. A person's features [age, height, weight] form a vector. In language models, a word is represented as a vector of hundreds of numbers (an embedding).
Matrices
A matrix is a table of numbers. A dataset with 1,000 people and 3 features is a 1,000 by 3 matrix. Neural-network layers are matrices of weights.
Dot product
Multiply matching elements and add them. It measures how much two vectors point in the same direction, and it is the core operation of neurons and attention.
Matrix multiplication
Applies many dot products at once. A neural-network layer computes output = input @ weights + bias.
Norms and distance
The length of a vector, and the distance between two vectors, show how similar items are.
import numpy as np
a = np.array([1.0, 2.0, 3.0])
b = np.array([2.0, 0.5, 1.0])
dot = a @ b # dot product
cosine = dot / (np.linalg.norm(a) * np.linalg.norm(b)) # similarity from -1 to 1
distance = np.linalg.norm(a - b) # Euclidean distance
print(dot, round(cosine, 3), round(distance, 3))
W = np.array([[0.2, -0.5], [0.8, 0.1], [-0.3, 0.7]]) # weights: 3 inputs -> 2 outputs
bias = np.array([0.1, -0.2])
layer_output = a @ W + bias # one neural-network layer
print(layer_output)
Where it appears
Embeddings, similarity search, neural-network layers, principal component analysis, recommender systems and image data (pixels as matrices).
2. Calculus: how models learn
Learning means improving a model by adjusting its parameters to reduce error.
Derivatives
A derivative tells you how a function changes when its input changes slightly. It is the slope of a curve.
Gradients
For functions of many variables, the gradient is the vector of partial derivatives, pointing toward the steepest increase. Moving in the opposite direction reduces the loss. This is gradient descent.
The chain rule
Derivatives of composed functions multiply. Backpropagation applies the chain rule through the layers of a network to find how each weight affects the loss.
# minimise f(x) = (x - 3)^2 with gradient descent
x = 0.0
learning_rate = 0.1
for step in range(30):
gradient = 2 * (x - 3) # derivative of (x-3)^2
x -= learning_rate * gradient
print(round(x, 4)) # close to 3
You rarely compute derivatives by hand, because libraries do automatic differentiation, but understanding gradients explains learning rates, vanishing gradients and why training sometimes fails.
3. Probability: reasoning under uncertainty
Machine learning deals with noisy data and uncertain predictions.
Basic ideas
- Probability: a number between 0 and 1 expressing how likely an event is.
- Random variables and distributions: descriptions of possible values and how likely they are. The normal (Gaussian) distribution, Bernoulli (yes/no) and categorical distributions appear everywhere.
- Expectation and variance: average value and spread.
- Conditional probability: the chance of A given B.
- Bayes' rule: how to update beliefs with evidence:
P(A|B) = P(B|A) × P(A) / P(B). - Independence: when events do not influence each other.
Where it appears
Classification outputs (probabilities from softmax), spam filters (Naive Bayes), language models (probability of the next token), uncertainty estimates, sampling in generative models and the loss functions used for training (cross-entropy comes from probability).
# Bayes' rule: a test is 99% sensitive and 95% specific; disease affects 1% of people
sensitivity, specificity, prevalence = 0.99, 0.95, 0.01
p_positive = sensitivity * prevalence + (1 - specificity) * (1 - prevalence)
p_disease_given_positive = sensitivity * prevalence / p_positive
print(f"{p_disease_given_positive:.1%}") # about 16.7%
The surprising result (only about 17% even after a positive test) shows why probability intuition matters when the condition is rare.
4. Statistics: learning from samples
- Descriptive statistics: mean, median, standard deviation, quantiles.
- Sampling and bias: whether your data represents the population.
- Correlation versus causation.
- Hypothesis testing and confidence intervals: judging whether differences are real or noise, as in A/B tests.
- Regression: modelling relationships.
- Overfitting and generalisation: why we use train, validation and test sets.
5. Optimisation: finding good parameters
Beyond plain gradient descent, practitioners use variants such as stochastic gradient descent (using small batches), momentum and Adam, which adapt the step size. Concepts like learning rate, local minima and convex versus non-convex problems help explain training behaviour.
A study plan
- Weeks 1 to 3: vectors, matrices, dot products with NumPy. Visualise vectors in 2D.
- Weeks 4 to 6: derivatives, gradients and gradient descent. Implement linear regression by gradient descent.
- Weeks 7 to 9: probability basics, Bayes' rule and distributions. Simulate with random numbers.
- Weeks 10 to 12: statistics and evaluation: correlation, confidence intervals, A/B testing.
- Throughout: apply each idea in code and in a small project.
Good approaches are interactive videos, books that mix theory and code, and exercises where you plot and simulate results.
How much is enough?
- To use AI tools and APIs: very little.
- To work as a practical machine-learning engineer: the essentials above, applied through code.
- To do research or build new architectures: deeper linear algebra, multivariable calculus, probability theory and optimisation.
You can learn maths progressively, driven by the projects you build.
Frequently Asked Questions
Can I learn AI without strong maths?
You can start and build useful things, but gaps will limit debugging and advanced understanding. Learn the basics alongside practice.
Which topic is most important?
Linear algebra and probability are used constantly, and calculus explains how training works.
Do I need to memorise formulas?
No. Understand the ideas and know where to look things up.
Is statistics different from machine learning?
They overlap. Statistics emphasises inference and uncertainty; machine learning emphasises prediction. A data practitioner benefits from both.
Conclusion
Linear algebra represents data and computation, calculus drives learning, and probability and statistics handle uncertainty. Learn them in small steps, always with code, and AI methods will become far less mysterious.