The Maths You Actually NeedLesson 43 of 76

Module 5 · Logarithms, information and the shape of a loss

Entropy: the average surprise, computed by hand

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 5 of 10 in this chapter

This chapter’s goalCompute a cross-entropy and a KL divergence by hand from two small distributions and say which part of a training loss is irreducible, derive the squared-error and cross-entropy losses from a stated noise assumption, compute a softmax and its gradient for a given set of logits, and explain by the overflow limit of float32 why every library subtracts the maximum before exponentiating.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 9Free · no account needed
Lesson steps

The definition, and one calculation

Entropy is the average surprise of a distribution: what you expect to pay per outcome, in bits, if outcomes arrive according to that distribution.

Text
H(p) = − Σ p_i × log2(p_i)

Do one by hand and it stops being a formula. Four outcomes with probabilities 0.5, 0.25, 0.125 and 0.125:

Text
0.5   × 1 bit  = 0.500
0.25  × 2 bits = 0.500
0.125 × 3 bits = 0.375
0.125 × 3 bits = 0.375
                 -----
H = 1.75 bits

The surprise of each outcome, weighted by how often it happens. Note that the rare outcomes cost three bits each but only occur an eighth of the time, so they contribute less than the common one.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Entropy: the average surprise, computed by hand’, in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/entropy-by-hand (Accessed: 29 November 2026).