Formulas, decoded symbol by symbol.

18 formulas from statistics, machine learning and LLMs. Each in plain words, every symbol explained, and a worked example, most with numbers from our own tools. For the words around them, see the glossary.

Mean

Statistics

Add up the values and divide by how many there are.

Tap a symbol to see what it means.

x
the mean, “x bar”
Σ
add up, over every value
xi
each value in turn
n
how many values there are

Worked example

Five delivery times (made-up), 28, 35, 31, 42, 39 minutes: (28 + 35 + 31 + 42 + 39) ÷ 5 = 175 ÷ 5 = 35 minutes.

Standard deviation (of a sample)

Statistics

How far values typically sit from their mean: average the squared distances (dividing by n − 1), then take the square root.

Tap a symbol to see what it means.

s
the standard deviation
Σ
add up, over every value
xi
each value
x
the mean
n
how many values (n − 1 corrects for using the sample’s own mean)

Worked example

The same times: distances from 35 are -7, 0, -4, 7, 4; their squares add to 130; 130 ÷ 4 = 32.5; √32.5 = 5.70 minutes.

z-score

Statistics

How many standard deviations a value sits above (or below) the mean.

Tap a symbol to see what it means.

z
the z-score
x
the value
μ
the mean, “mu”
σ
the standard deviation, “sigma”

Worked example

A 42-minute delivery, with mean 35 and standard deviation 5.70: (42 − 35) ÷ 5.70 = 1.23, about one and a quarter standard deviations slow.

Standard error of a mean

Statistics

How much a sample’s mean would wobble from sample to sample: the spread divided by the square root of the sample size.

Tap a symbol to see what it means.

SE
the standard error
σ
the spread of single values
n
the sample size

Worked example

One roll of a die has a spread of 1.71. Averages of 30 rolls: 1.71 ÷ √30 = 0.31, and the central limit theorem simulator’s 1,000 averages had a spread of 0.30.

Watch it in the central limit theorem simulator

95% confidence interval

Statistics

An estimate, plus and minus about two standard errors: a range made by a method that catches the true value 95% of the time.

Tap a symbol to see what it means.

θ
the estimate, such as a mean or a difference
1.96
how many standard errors cover the middle 95% of a normal curve
SE
the estimate’s standard error

Worked example

In the A/B test calculator’s example, B converts 4.52% and A 4.00%: a difference of 0.52 points, with a standard error of 0.286. So 0.52 ± 1.96 × 0.286 = -0.04 to +1.08 points, which includes zero.

Try it in the A/B test calculator

Two-proportion z-test

Statistics

Is B’s rate really different from A’s? The difference, divided by how much it would wobble if there were no difference.

Tap a symbol to see what it means.

z
how many standard errors apart the rates are
pB
B’s conversion rate
pA
A’s conversion rate
p
both versions’ rate pooled together
n
each version’s visitors

Worked example

400 of 10,000 against 452 of 10,000: z = 1.82, so the p-value, the chance of a gap this big if the versions were the same, is 0.069: not significant at 0.05.

Check your own test in the A/B test calculator

Linear regression

Machine learning

A prediction as a starting value plus a fixed amount for each unit of the feature.

Tap a symbol to see what it means.

ŷ
the prediction, “y hat”
β0
the intercept: the prediction when x is 0
β1
the slope: the change in ŷ for each unit of x
x
the feature

Worked example

A made-up line, ŷ = 20 + 3x: at x = 4, ŷ = 20 + 3 × 4 = 32. With more features, each gets its own β.

R²

Machine learning

The share of the target’s variation the model explains: 1 minus its squared errors over the squared distances from the mean.

Tap a symbol to see what it means.

R²
the share explained, at most 1
Σ
add up, over every point
yi
each true value
ŷi
each prediction
y
the mean of the true values

Worked example

The overfitting playground’s degree-3 curve, on its 200 new points: R² = 0.77. Degree 15’s wild curve scores far below zero: worse than predicting the mean every time.

See both curves in the overfitting playground

Accuracy

Machine learning

The share of all predictions that are right.

Tap a symbol to see what it means.

Accuracy
the share right
TP
true positives: predicted yes, really yes
TN
true negatives: predicted no, really no
all
every prediction

Worked example

The confusion matrix’s churn model at 0.5: (45 + 583) ÷ 1,000 = 62.8%. Saying nobody leaves scores 93.1%, which is why accuracy misleads when one class is rare.

Move the line in the confusion matrix

Precision

Machine learning

Of everything flagged positive, the share that really is.

Tap a symbol to see what it means.

Precision
how often a “yes” is right
TP
true positives
FP
false positives: flagged, but really no

Worked example

The churn model at 0.5 calls 393 customers and 45 of them were leaving: 45 ÷ (45 + 348) = 11.5%.

Move the line in the confusion matrix

Recall

Machine learning

Of everything really positive, the share the model finds.

Tap a symbol to see what it means.

Recall
how many of the real yeses it finds
TP
true positives
FN
false negatives: missed, really yes

Worked example

69 customers left and the model at 0.5 flagged 45 of them: 45 ÷ (45 + 24) = 65.2%.

Move the line in the confusion matrix

F1 score

Machine learning

Precision and recall in one number, their harmonic mean, which stays low if either is low.

Tap a symbol to see what it means.

F₁
the F1 score, 0 to 1
P
precision
R
recall

Worked example

With precision 0.115 and recall 0.652: 2 × 0.115 × 0.652 ÷ (0.115 + 0.652) = 0.19, much nearer the lower of the two.

Find the best F1 in the confusion matrix

Log loss (cross-entropy)

Machine learning

How wrong predicted probabilities are; a confident wrong answer costs the most.

Tap a symbol to see what it means.

L
the loss for one prediction (averaged over all of them)
y
the truth: 1 or 0
p
the predicted probability of 1

Worked example

A customer who left (y = 1): predicted 0.8, the loss is −log 0.8 = 0.223; predicted 0.2, it’s −log 0.2 = 1.609, seven times as much.

Softmax

LLMs

Turns any list of scores into probabilities that add up to 1, giving the biggest score the biggest share.

Tap a symbol to see what it means.

pi
the probability of item i
zi
item i’s score (a logit)
Σ
add up, over every item j
zj
every item’s score

Worked example

Made-up scores 2, 1, 0.1 become 0.659, 0.242, 0.099. A language model does this over its whole vocabulary, 151,936 tokens for Qwen 3, at every step.

Lesson 4: picking the next token

Softmax with temperature

LLMs

Divide every score by T first: below 1 sharpens the choice, above 1 flattens it.

Tap a symbol to see what it means.

pi
the probability of item i
zi
item i’s score
T
the temperature
Σ
add up, over every item j
zj
every item’s score

Worked example

The same scores, 2, 1, 0.1: at T = 0.5 they become 0.864, 0.117, 0.019; at T = 2, 0.502, 0.304, 0.194.

Move it in the temperature playground

Cosine similarity

LLMs

How alike two lists of numbers are by the angle between them: multiply them position by position, add up, divide by both lengths.

Tap a symbol to see what it means.

cos θ
the similarity, from −1 to 1
a
the first vector (embedding)
b
the second vector
·
the dot product: multiply position by position, then add

Worked example

Two made-up vectors, [3, 4] and [4, 3]: (3×4 + 4×3) ÷ (5 × 5) = 0.96. bge-small-en-v1.5 rates “How do I get a refund?” and “Can I get my money back?” at 0.87 across its 384 numbers.

Lesson 2: embeddings

Scaled dot-product attention

LLMs

Score each token’s key against a query, scale, turn the scores into shares, and mix the values by those shares.

Tap a symbol to see what it means.

Attention
each token’s new, mixed vector
softmax
scores into shares that add to 1
Q
the queries: what each token looks for
K
the keys: what each token offers
dk
the size of a key, whose square root scales the scores
V
the values: what each token passes on

Worked example

In lesson 3’s worked example, “bank” gives 37.0% of its mix to “river”, the most of any token.

Lesson 3: attention, step by step

KV cache memory

LLMs

A key and a value, for every layer, every key-value head and every number in a head, at so many bytes each, for every token.

Tap a symbol to see what it means.

bytes
the cache’s size
L
the layers
hkv
the key-value heads in a layer
d
the numbers in each head
b
bytes a number: 2 in 16-bit
t
the tokens held

Worked example

Qwen 3 (8B), from its config: 2 × 36 × 8 × 128 × 2 = 1,47,456 bytes a token; for 32,768 tokens, about 4.8 GB.

Lesson 5: the KV cache calculator

Maths without the fear.

  • Words first

    Every formula starts as a sentence. Read that, and the symbols are just short names for its parts.

  • Real numbers

    The worked examples use numbers from our own tools where there is one, so you can open the tool and see the same number.

  • Say it in an interview

    Interviewers rarely want the derivation. They want you to say what each part does and why it’s there.