The Maths You Actually NeedLesson 42 of 76

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

Surprise, bits, and why prediction is compression

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 4 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 8Free · no account needed
Lesson steps

Measuring surprise

If something you were sure of happens, you learn nothing. If something you thought impossible happens, you learn a great deal. Information theory turns that into a number: the surprise of an outcome with probability p is

Text
surprise = −log2(p)   bits

A fair coin landing heads has p = 0.5, so −log2(0.5) = 1 bit. A specific card from a shuffled pack has p = 1/52, so 5.7 bits. An outcome with p = 0.9 is worth −log2(0.9) = 0.152 bits: mild. An outcome with p = 1 is worth exactly zero.

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) ‘Surprise, bits, and why prediction is compression’, in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/surprise-and-bits (Accessed: 29 November 2026).