part three

Part 3 Probabilities

 

Generating random numbers that match a desired distribution is common in games, simulations, and other applications, but the way we represent random numbers in most programming languages is limited. We’ve built libraries for high-level manipulation of sequences; we could do the same for probability distributions. In this part, we’ll sketch out a library of operators for manipulating probabilistic quantities.

A more powerful API is great, but we should aim higher. Modern programs often must automate important decisions in a world full of uncertainty, and our programming tools should help us make principled, evidence-based decisions.

Suppose I have an algorithm that is on average 99.9% accurate at determining whether a new account on a major social media site is a real person (good) or a bot (bad). If my algorithm predicted that a specific new account was a bot, would you delete that account? I hope not; my algorithm is “every new account is a bot”. Because approximately 99.9% of new accounts on major social media sites are bots, my algorithm is about 99.9% accurate, but plainly, it’s not acceptable to put it into production. How can we do better?

In chapter 12, we’ll sketch out a new interface for discrete probability distributions and implement algorithms to efficiently simulate rolling unfair dice.