Algorithmic Game Theory · Lecture Notes
Chapter 0: Preliminaries
Game theory studies the interdependent choices of several decision makers. To state those choices precisely and to compute their consequences, a small but solid body of mathematics is needed: sets and functions, sums and maxima, derivatives, probability and expected value, reading matrices, simple equations, and trees. These notes introduce the tools used throughout the course one at a time, from scratch, and always through game examples. Each concept is first explained in plain language, then defined formally, and followed by a fully worked example with every step shown and a common mistake. The notes are written so that a reader with a weak mathematical background can use them on their own.
Learning outcomes
- Notation
- Read sets, Cartesian products, and function notation such as u1(s1, s2).
- Σ, max, argmax
- Evaluate sums and geometric series; find the maximum value and the choice that attains it, using derivatives (chain rule, partial derivatives) when the choice is continuous.
- Probability
- Compute probabilities by counting, by multiplying, and by conditioning (Bayes); work with U[0, 1].
- Expected value
- Compute the expected payoff of a lottery and of a mixed strategy; read expressions with exponentials, ln, and softmax.
- Matrices and best responses
- Read an (a, b) pair correctly and mark best responses in a payoff matrix.
- Equations and trees
- Solve quadratic and indifference equations; solve a game tree from the leaves to the root; read growth rates with O and Θ.
0.1Introduction
This chapter introduces no new game-theoretic concept. Its purpose is to present the language that game theory speaks. That language consists of a few symbols, a few rules of calculation, and a few habits of reading, and all of it is made concrete through one small game: Rock-Paper-Scissors.
0.1.1Starting with a game: Rock-Paper-Scissors
Two players simultaneously choose Rock, Paper, or Scissors. Rock beats Scissors, Scissors beats Paper, and Paper beats Rock; equal choices end in a tie. The winner gains 1 point, the loser gives up 1 point, and in a tie nobody scores. Figure 0.1 shows this beating relation as a cycle: each arrow points from a move to the move it beats.
The cycle has an important consequence: there is no single "best move." Rock is good against Scissors but bad against Paper. Which move is good depends entirely on what the opponent plays. That dependence is the whole subject of game theory: a player's payoff depends not only on her own choice but also on the choice of the opponent.
Suppose we play against a computer. The computer can behave in two ways. In the first, it picks a random move each round. In the second, it watches our moves: it learns how often we play each move, or which move we tend to play after which, and plays accordingly. Against the second kind of computer, two questions arise naturally:
- Is there a way of playing that a learning computer cannot beat in the long run?
- If someone always plays Rock and the opponent notices, how many points per round does she lose on average?
The tools needed to answer these questions are the following: set and function notation to write down moves and outcomes; probability and expected value for the question "how many points on average"; argmax and best response for the question "which move is best"; and the indifference equation for "a way of playing that cannot be beaten." Once these tools have been built up in turn, both questions are answered completely (0.9.5).
0.1.2The role of mathematics in game theory
The first role of mathematics in game theory is as a notation. The sentence "If Ayşe plays Rock and Bora plays Scissors, Ayşe gets 1 point" is long and ambiguous; the same information is written briefly and exactly as u1(Rock, Scissors) = 1. As games grow, this brevity becomes a necessity: it is impossible to describe all the outcomes of a ten-player game in sentences.
The second role is computation. When a player asks "if my opponent plays Rock half of the time, what should I do?", the answer is a comparison of numbers: compute the average payoff of each move and pick the largest. Probability, sums, and finding a maximum are enough for this. When the choice is continuous (such as how many units a firm produces), the maximum is found with a derivative.
The third role is measurement. How long a method will take on a computer is described by its growth rate as a function of the input size. This is where the "algorithmic" in algorithmic game theory comes from: is it possible to find an equilibrium, and if so, how fast? The language of these questions is O and Θ notation (0.10.3).
Every section of these notes follows the same order: first a plain explanation of the concept, then its formal definition, then why it matters, then a worked example, and finally the most common mistake. The numbers in the examples are the same as the numbers in the slides.
0.2Sets and functions
Writing down a game takes three things: who plays, what options each player has, and who gets what in each situation. The options are written as a set, "each situation" as a Cartesian product, and "who gets what" as a function. The counting rules are closely tied to these three structures as well.
0.2.1Sets and the Cartesian product
A set is an unordered collection of objects. In game theory the most common set is the list of a player's options. A set is written with curly braces: {Rock, Paper, Scissors}. Order does not matter in a set; {Rock, Paper} and {Paper, Rock} are the same set. An element is not written twice in a set.
If a is an element of a set A, we write a ∈ A, read "a is an element of A." The number of elements of a set is written |A|.
The Cartesian product of two sets A and B is the set of all ordered pairs whose first element comes from A and whose second element comes from B:
A × B = {(a, b) : a ∈ A, b ∈ B}
The sizes multiply: |A × B| = |A| · |B|.
The word "ordered" in the definition is crucial. Order does not matter in a set, but it does in a pair: in the pair (a, b), the first slot belongs to A and the second to B. Two pairs are equal only if the elements in both slots are the same.
In game theory, a player's options are called strategies, and the set of all of a player's options is called her strategy set. Player 1's strategy set is written S1 and player 2's S2. In one round of the game each player picks a strategy. The pair formed by the two players' choices together is called a strategy profile. The set of all possible profiles is exactly the Cartesian product S1 × S2. The Cartesian product is thus a complete answer to the question "what can happen in the game?"
Ayşe and Bora play Rock-Paper-Scissors. Ayşe's strategy set is S1 = {Rock, Paper, Scissors}.
- Rock is one of Ayşe's strategies: Rock ∈ S1. The set has three elements: |S1| = 3.
- Bora's options are the same: S2 = {Rock, Paper, Scissors}, |S2| = 3.
- A profile is built by writing Ayşe's choice in the first slot and Bora's in the second. Each of Ayşe's choices is paired with each of Bora's: three pairs with Rock, three with Paper, three with Scissors.
- The total number of profiles is |S1 × S2| = 3 · 3 = 9.
The nine profiles are arranged as a three-by-three table in Figure 0.2. Rows are Ayşe's choices, columns are Bora's; each cell is a profile.
The table form is no accident. The profiles of every two-player game can be arranged in such a table; when payoffs are written in the cells, the table becomes a payoff matrix (0.7). In a three-player game, profiles are lists of three elements: (s1, s2, s3) ∈ S1 × S2 × S3. Such lists are called triples, or n-tuples in general. The counting rule is the same: the sizes multiply.
Treating (Rock, Paper) and (Paper, Rock) as the same. Order matters in a pair: the first element is Ayşe's choice and the second is Bora's. In the profile (Rock, Paper), Ayşe played Rock and Bora played Paper, and Bora wins. In (Paper, Rock) the roles are swapped and Ayşe wins. These are two different outcomes, one won by Ayşe and the other by Bora (the orange cells in Figure 0.2). This confusion also leads to a wrong count: someone who thinks without order finds six outcomes instead of nine.
0.2.2Function notation
A function can be pictured as a machine: it takes an input and returns exactly one output. The same input always gives the same output. The most important function in game theory is the payoff function. Its input is a strategy profile and its output is a number: the points a player receives when that profile is played.
The notation f : X → Y says that f is a function that assigns to each element of the set X exactly one element of the set Y. The element assigned to x is written f(x).
The payoff function of player i is ui : S1 × S2 → ℝ, where ℝ is the set of real numbers. The notation reads "from profiles to real numbers."
The subscript in the notation says whose payoff is being looked at. For the same profile, u1 gives Ayşe's payoff and u2 gives Bora's. These two numbers are usually different. The two strategies inside the parentheses carry the profile, that is, the answer to "who played what?"; their order is the same as in the Cartesian product.
Let us read a few payoff values in Rock-Paper-Scissors one by one.
- u1(Rock, Scissors): Ayşe played Rock and Bora played Scissors. Rock beats Scissors, so Ayşe gets 1 point. The value is 1.
- u2(Rock, Scissors): The same profile, but now we ask for Bora's payoff. Bora lost and gives up 1 point. The value is −1.
- u1(Paper, Paper): A tie. The value is 0.
- u1(Rock, Paper): Paper beats Rock; Ayşe is the loser. The value is −1.
In this game u1 + u2 = 0 in every profile: what one player wins, the other loses. Games with this property are called zero-sum games.
Figure 0.3 shows the same input going into two different machines. In a game each player has her own payoff function. Describing a game completely means giving, for every player, the value of this function at every profile. In two-player Rock-Paper-Scissors that comes to 2 · 9 = 18 numbers.
Why is function notation so important? Because every definition in game theory is written in it. For example, the sentence "If Ayşe knows that Bora plays Scissors, she prefers Rock to Paper" is expressed by the inequality u1(Rock, Scissors) > u1(Paper, Scissors), that is, 1 > −1. Once the notation can be read, the definitions can be read too.
Reading the value of u1(Rock, Paper) as "Paper wins." The value of the function is a number, not a word: u1(Rock, Paper) = −1. The subscript says whose payoff is being looked at; u1 and u2 give different numbers for the same profile. Someone who skips the subscript may mistake Bora's payoff for Ayşe's.
0.2.3Counting: the product rule, n!, and C(n, k)
A frequent question in game theory is "how many?": how many strategy profiles are there, how many pure strategies does a player have, how many leaves does a tree have? Three simple counting rules answer these questions. The same rules are used in probability calculations, because for equally likely outcomes a probability is a ratio of counts (0.5.1).
- Product rule: In successive choices, if the first choice has a options and the second has b, the two choices can be made together in a · b different ways. With more choices, the numbers of options are multiplied in the same way.
- Factorial: n distinct objects can be arranged in n! = n · (n − 1) · … · 2 · 1 different orders. By definition 0! = 1.
- Combination (binomial coefficient): the number of ways to choose k of n distinct objects when order does not matter is
C(n, k) = n! / (k! · (n − k)!)
The product rule is the general form of the rule for the size of a Cartesian product. The factorial is a special application of the product rule: the first position of an ordering is filled by one of n objects, the second by one of the remaining n − 1, and so on. Combinations count choices in which order is irrelevant. The formula can be understood as follows: choosing k of n objects in order can be done in n · (n − 1) · … · (n − k + 1) = n!/(n − k)! ways. In this count the same k objects have been counted separately in k! different orders. When order is irrelevant, each group must be counted once, so we divide by k!.
- Number of profiles. Three players have 2, 3, and 4 strategies respectively. A profile is built by choosing one strategy from each player. By the product rule: 2 · 3 · 4 = 24 strategy profiles.
- Orderings. Three people are to be lined up. The first position can be filled by 3 people, the second by the remaining 2, the third by the remaining 1: 3! = 3 · 2 · 1 = 6 different orders.
- The guard's choice. A guard can protect 2 of 4 targets. Which two targets she protects is one of her pure strategies. Order is irrelevant; protecting A first and then B is the same strategy as protecting B first and then A. The count is C(4, 2) = 4!/(2! · 2!) = 24/4 = 6: {A, B}, {A, C}, {A, D}, {B, C}, {B, D}, {C, D} (Figure 0.4).
- A larger example. If 5 of 20 targets are to be protected, there are C(20, 5) = (20 · 19 · 18 · 17 · 16)/(5 · 4 · 3 · 2 · 1) = 1,860,480 / 120 = 15,504 pure strategies.
The growth in the last example is striking. When the number of targets goes from 4 to 20 and the number of protected targets from 2 to 5, the number of pure strategies goes from 6 to 15,504. In real security applications (airports, ports, forest patrols) the number of targets is in the hundreds. Methods that list strategies one by one therefore quickly become inadequate. This rapid growth in the number of strategies gives rise to one of the basic questions of algorithmic game theory: among an astronomical number of strategies, can a computer find the best one quickly?
Counting order in a choice where order is irrelevant. Choosing from 4 targets as "first one, then another" gives 4 · 3 = 12 ordered pairs. But {A, B} and {B, A} are the same protection; every choice has been counted twice. The correct number is 12 / 2! = 6. The opposite mistake also occurs: in a Cartesian product order matters, and (Rock, Paper) and (Paper, Rock) must be counted separately. A single question decides which rule to use: "does swapping the order give something different?"
0.3Sums and maxima
Most computations in game theory consist of two operations: adding things up and picking the largest. An expected payoff is a sum; a best response is a choice of the largest value; the total payoff in a repeated game is an infinite sum. When there are infinitely many options, the maximum is found with a derivative.
0.3.1The summation symbol Σ
Σ is the capital Greek letter "sigma" and means "add them all up." It lets long sums be written briefly. The expression below the symbol says where the summation starts, the number above it says where it stops, and the expression to its right is what is added at each step.
Σi=1n xi = x1 + x2 + … + xn
Here i is a counter: first it is 1, then 2, …, and finally n. For each value of the counter we write xi and add them all.
The name of the counter does not matter; writing j or k instead of i does not change the sum. What matters is which values the counter runs through and what is added for each value. In some sums the limits are not written and the summation runs "over all possible values." For example, Σx x · P(X = x) adds one term for every value x that X can take.
Two rules are used often when working with Σ. First, a constant factor common to every term can be taken outside the sum: Σ c · xi = c · Σ xi. Second, the sum of two sums can be written as a single sum: Σ (xi + yi) = Σ xi + Σ yi. Both rules follow from the fact that the order and grouping of addition do not change the result.
A die is rolled three times and shows 4, 1, and 6 in turn: x1 = 4, x2 = 1, x3 = 6 (Figure 0.5).
- Write the sum out: Σi=13 xi = x1 + x2 + x3.
- Substitute the values: 4 + 1 + 6 = 11.
- On a fair die each face has probability pi = 1/6. The probabilities of the six faces add up to Σi=16 pi = 6 · 1/6 = 1. This uses the constant-factor rule: all six terms are the same. The fact that probabilities sum to 1 holds for every distribution.
- An expected value is also a sum: Σi=1n xi · pi. This sum is treated in detail in 0.5.5.
The Σ notation is the mathematical counterpart of a loop in programming. Σi=13 xi means "total = 0; for each i from 1 to 3, add x[i] to total." This similarity is plain in the code that computes the expected value of a lottery (0.5.6).
Moving the square outside the sum. (Σ xi)² and Σ xi² are different. The first adds first and then squares: (4 + 1 + 6)² = 11² = 121. The second squares each term first and then adds: 4² + 1² + 6² = 16 + 1 + 36 = 53. The right procedure is to evaluate the expression inside Σ separately for each i and then add the results. A constant factor can be taken outside, but a square or any other operation cannot.
0.3.2Geometric series and the discount factor δ
Some games are played once and end; others are played again and again between the same players. Two firms set prices every month; two neighbors meet every day. In repeated games, today's payoff has to be compared with future payoffs. People generally prefer a payoff today to the same payoff later; moreover, it may be uncertain whether the game will continue into the next round. Both effects are modeled with a single number, the discount factor.
The discount factor is a number 0 ≤ δ < 1. A payoff received t rounds from now is multiplied by δt when viewed from today: a payoff of 1 today is worth 1, one round later it is worth δ, two rounds later δ².
If the payoff in every round is 1, the infinite sum starting today is a geometric series:
1 + δ + δ² + δ³ + … = 1/(1 − δ)
At first sight this formula is surprising: infinitely many positive numbers are added, yet the result is a finite number. The reason is that the terms shrink quickly. For δ = 1/2 the terms are 1, 1/2, 1/4, 1/8, …, halving at every step (Figure 0.6). The sum gets a little closer to 2 at each step but never exceeds it.
If 0 ≤ δ < 1, then S = Σt=0∞ δt = 1/(1 − δ).
Denote the sum by S: S = 1 + δ + δ² + δ³ + …. Multiplying both sides by δ raises the exponent of every term by one: δS = δ + δ² + δ³ + …. Writing the two lines one under the other, we see that every term of the second line also appears in the first; the only extra term in the first line is the leading 1. So subtracting the second line from the first leaves only that term: S − δS = 1. The left side is written S(1 − δ). Since δ < 1, the number 1 − δ is nonzero and both sides can be divided by it: S = 1/(1 − δ). (This derivation assumes that S is a finite number; for δ < 1 the assumption is correct, because the terms shrink quickly.) □
If the payoff in each round is not 1 but a, the constant-factor rule makes the sum a/(1 − δ). If the sum starts one round from now rather than today, each term carries an extra δ: δ + δ² + … = δ · (1 + δ + …) = δ/(1 − δ).
- δ = 0.9 and a payoff of 3 each round. The sum is 3 + 3 · 0.9 + 3 · 0.9² + … = 3/(1 − 0.9) = 3/0.1 = 30.
- δ = 1/2 and a payoff of 1 each round. 1 + 1/2 + 1/4 + … = 1/(1 − 1/2) = 1/(1/2) = 2. The first few partial sums are 1, 1.5, 1.75, 1.875, approaching 2.
- A sum that starts tomorrow. If, with δ = 0.9, the payoff of 3 per round starts tomorrow rather than today, the sum is 3 · 0.9/(1 − 0.9) = 2.7/0.1 = 27. The difference is today's 3: 30 − 27 = 3.
The importance of this formula in game theory is as follows. In a repeated game, if two players cooperate continually, each receives a certain payoff every round; if one cheats once, she gains more in that round but may be punished in later rounds. Whether cheating pays is decided by comparing the one-time gain with the present value of the payoffs that will be lost later. That present value is exactly a geometric series. When δ is large (the players are patient, or the game is likely to continue), the future weighs heavily and cooperation can be sustained.
Forgetting the first term. A sum that begins "after today" is δ + δ² + … = δ/(1 − δ), not 1/(1 − δ). Which formula to use is chosen by looking at the round in which the first payoff arrives. A second mistake is to use the formula for δ = 1: then the denominator is zero and the formula is invalid. Indeed, the sum 1 + 1 + 1 + … grows without bound.
0.3.3max and argmax
When a player decides, she looks at what each of her options would bring and picks the one that brings the most. This thought contains two separate questions: "how much can be won at most?" and "which option brings the most?" The answer to the first is a number; the answer to the second is an option. The two questions are written with two different notations.
Let A be the set of options and let f(a) be the value of each option.
- maxa ∈ A f(a): the largest of the values. It is a number.
- argmaxa ∈ A f(a): the set of options that attain the largest value. If there is no tie it has one element, and that one element is often written instead.
In game theory a player chooses an action, not a value. That is why argmax is used more often. A player's "best response" is the argmax of her own payoff against the opponent's choice (0.8). The max then tells the payoff that this best response brings.
One of four face-down cards is to be chosen. The prizes on the cards are A: 3, B: 7, C: 2, D: 5 chips.
- Write the values side by side: f(A) = 3, f(B) = 7, f(C) = 2, f(D) = 5.
- Find the largest value: max{3, 7, 2, 5} = 7. This is a number.
- Find the option that gives this value: only B gives 7. argmax = B. This is an option and it is the decision itself: "choose B."
Figure 0.7 separates the two concepts visually: max is the height of the bar, argmax is the label under the bar. The distinction may look unimportant at first, but in many definitions of game theory max and argmax appear together on the same line. Writing one in place of the other makes the definition meaningless.
Writing the value in place of the argmax ("argmax = 7") or the reverse ("max = B"). The second trap is a tie. If the prizes were 3, 7, 2, 7, the argmax would not be a single element but the set {B, D}; both are best choices. Picking one "at random" in a tie and forgetting the other causes some equilibria to be overlooked in game theory, because a player's indifference between two options is the basis of mixed strategies (0.9.3).
0.3.4Code trace: finding the argmax with a loop
A computer finds an argmax with a loop. The Python code below is the same as the code in the slides. This time the prizes are deliberately chosen with a tie: 3, 7, 2, 7. B and D are tied for the largest, so we can see how the code behaves on a tie.
action = ["A", "B", "C", "D"]
payoff = [3, 7, 2, 7]
best = 0 # index of the best
for i in range(1, 4):
if payoff[i] > payoff[best]:
best = i
print(payoff[best], action[best])The lines of the code work as follows:
actionholds the names of the options andpayoffholds the prizes in the same order. The two lists are matched by index: index 0 corresponds to A and to 3, index 1 to B and to 7.best = 0: at the start the first card (A, 3 chips) is taken to be the best. The variable holds an index, not a value; this is the code counterpart of the fact that an argmax is an option.- The loop runs for
i = 1, 2, 3.range(1, 4)starts at 1 and does not include 4. Index 0 is skipped because the first card is already the starting candidate. - At each step the prize of the card being examined is compared with the prize of the best so far. If it is strictly larger, the best is updated.
- At the end the prize of the best (the max) and its name (the argmax) are printed.
| Step | i | Comparison | Result | best |
|---|---|---|---|---|
| Start | – | – | A is the candidate | 0 (A, 3) |
| 1 | 1 | 7 > 3? | yes | 1 (B, 7) |
| 2 | 2 | 2 > 7? | no | 1 (B, 7) |
| 3 | 3 | 7 > 7? | no | 1 (B, 7) |
| Output | – | – | 7 B | – |
Table 0.1 shows every step of the loop and Figure 0.8 shows the final state. The third step of the trace table contains an important detail. At the third step D's prize is 7 and the prize of the best is also 7. Because the comparison is strict "greater than" (>), 7 > 7 is false and the best does not change. On a tie the code keeps the first one found. The output is 7 B. Mathematically, however, the argmax set is {B, D}. The code has returned only one element of the set.
If the comparison were >=, the last tied element would be kept and the output would be 7 D. To find all the best options, two passes are made: first the max is found, then all indices whose prize equals the max are collected in a list. This detail matters in game-theory code. For example, a program that finds all equilibria of a matrix will miss some equilibria if it skips tied maxima.
The amount of work of the code is also easy to count. For n options the loop runs n − 1 times and makes one comparison per round. The work grows in proportion to the number of options; in the notation of 0.10.3 this is Θ(n). Since the maximum cannot be found without looking at every option at least once, there is no faster method.
0.3.5Maximum of a function: derivative equals zero
When the options are limited to a few cards, an argmax is read off a table. But some choices are continuous. A firm can produce 4 units, or 4.5 units, or 4.37 units. Because the number of options is infinite, no table can be written. In this case the maximum is found using the shape of the function's graph.
Think of the top of a hill. Climbing up, the path slopes upward; going down, it slopes downward. Right at the summit the path is flat for a moment: the slope is zero. The same holds for a smooth payoff curve: to the left of the peak the slope is positive, to the right it is negative, and at the peak it is zero. The function that gives the slope of a function at every point is called the derivative and is written f′(q).
f′(q) is the slope of the graph of f at the point q: it says how fast f changes when q increases by a tiny amount. The rules needed in these notes are:
- (qk)′ = k · qk−1; for example (q²)′ = 2q and (q)′ = 1.
- The derivative of a constant is 0.
- (c · f)′ = c · f′: a constant factor comes out of the derivative.
- The derivative of a sum is the sum of the derivatives: (f + g)′ = f′ + g′.
The derivative of the derivative is called the second derivative and is written f″. If f″ < 0, the slope is decreasing; a point where the slope is zero is then a peak.
The method has three steps: take the derivative, set it equal to zero, and solve the resulting equation. The point found is called a candidate, because not every point where the slope is zero is a peak. The slope is also zero at the bottom of a valley. A fourth step is therefore needed: check that the candidate really is a peak.
We look for the maximum of the function f(q) = q(10 − q).
- Expand. Multiply out: f(q) = 10q − q².
- Derivative. The derivative of 10q is 10 and the derivative of q² is 2q. By the sum rule, f′(q) = 10 − 2q.
- Set to zero. 10 − 2q = 0 ⇒ 2q = 10 ⇒ q = 5.
- Value. f(5) = 5 · (10 − 5) = 25.
- Check. The second derivative is f″(q) = −2, which is negative; the slope is decreasing, so the point is a peak. Neighboring values confirm it: f(4) = 4 · 6 = 24 and f(6) = 6 · 4 = 24; both are smaller than 25.
Result: argmax = 5, max = 25.
Figure 0.9 shows the geometric meaning of the derivative. The red line at q = 2 is tangent to the curve at that point and has slope 6: when q increases by a small amount, f increases by about 6 times as much. At the peak the tangent is horizontal. To the right of the peak, for example at q = 8, the slope is 10 − 16 = −6: as q grows, f falls.
Never checking the point where f′ = 0. It may be a valley; for example, for g(q) = q² we have g′(0) = 0, but 0 is the bottom of a valley. That it is a peak is shown by f″ < 0 or by neighboring values (f(4) = f(6) = 24 < 25). If the choice is restricted to an interval, the endpoints must also be examined: sometimes the maximum is not where the slope is zero but at an end of the allowed interval.
0.3.6The best quantity via derivatives
The first major application of the derivative method in game theory is to firms choosing production quantities. Two firms sell the same good. The market price depends on total production: the more is produced, the lower the price. A firm's profit depends not only on its own quantity but also on the opponent's quantity. This is a game.
The numbers of the model are as follows: the price is 12 − (q + r), where q is the firm's quantity and r is the opponent's. There is no production cost. Profit is quantity times price:
u(q) = q · (12 − q − r)
The opponent produces r = 4 units. We look for the firm's best quantity.
- Profit expression. u(q) = q · (12 − q − 4) = q(8 − q) = 8q − q².
- Derivative. u′(q) = 8 − 2q.
- Set to zero. 8 − 2q = 0 ⇒ q = 4.
- Profit. u(4) = 4 · (8 − 4) = 16. The price is 12 − 8 = 4; 4 units are sold at 4 each. The profit curve and its peak are shown in Figure 0.10.
- Check. u″ = −2 < 0. Neighbors: u(3) = 3 · 5 = 15 and u(5) = 5 · 3 = 15; both are smaller than 16 ✓.
The same computation could be repeated for every quantity of the opponent. Instead, we hold r like a constant and do the computation once, in general. Expanding the profit gives u(q) = 12q − q² − qr. Since r is constant, the derivative of qr with respect to q is r (constant-factor rule). The derivative is u′(q) = 12 − 2q − r, and setting it to zero gives
12 − 2q − r = 0 ⇒ q = (12 − r)/2
Putting in r = 4 gives q = 8/2 = 4, the result of the example. For r = 2, q = 5; for r = 6, q = 3: the more the opponent produces, the less the firm produces.
The formula has a limit: the quantity cannot be negative. If r ≥ 12 the formula gives zero or a negative number. In that case the price is already zero or below, and the firm's best choice is not to produce at all. The full formula is:
q*(r) = max{0, (12 − r)/2}
This formula, which gives the best answer to every quantity of the opponent, is the continuous version of the best response that is marked in a matrix in 0.8. In a matrix the best response is found by taking an argmax separately for each column; here the derivative gives the argmax for all the infinitely many "columns" in a single formula. The quantities at which the two firms best-respond to each other simultaneously are found with partial derivatives in 0.4.4.
Thinking that the opponent's quantity changes together with one's own. When the firm chooses q it cannot change r; for the firm r is a constant. So the derivative of the term qr is r, not q + r or 2qr. The second mistake is to forget the limit: for r = 14 the formula gives q = −1, but negative production is meaningless and the correct answer is q* = 0.
0.4Exponents, logarithms, and differentiation rules
In game theory, exponential expressions show up in three places: discounting in repeated games (δt), the utility of a risk-averse person (x0.88 or ln x), and probabilistic choice rules (eλv). Working with these expressions requires the rules for exponents and logarithms, and finding their maxima requires two new differentiation rules: the product rule and the chain rule. For functions of several variables, partial derivatives are used.
0.4.1Exponent rules and fractional exponents
In the expression xa, x is called the base and a the exponent. If a is a positive integer, xa is x multiplied by itself a times: x³ = x · x · x. The exponent rules follow directly from this definition and are then extended in the same way to fractional and negative exponents.
For x > 0 and any real numbers a, b:
- xa · xb = xa+b (exponents add when multiplying with the same base),
- (xa)b = xa·b (exponents multiply for a power of a power),
- x0 = 1,
- x−a = 1/xa,
- x1/2 = √x.
The reason for the rules is seen by counting. x² · x³ is the product of two x's and three x's; five x's are multiplied in all, that is, x5. The rule x0 = 1 also comes from the first rule: we must have xa · x0 = xa+0 = xa, so x0 must be the number that leaves a product unchanged, namely 1. The negative exponent follows by the same logic: since xa · x−a = x0 = 1, x−a is the reciprocal of xa. Finally, x1/2 · x1/2 = x1 = x; the positive number whose square is x is √x.
Fractional exponents (such as x0.88) obey the same rules. Their meaning can be stated in one sentence: if the exponent is positive and less than 1, xa increases ever more slowly as x grows. If the exponent is greater than 1, it increases ever faster. Figure 0.11 shows these two cases side by side, together with the case in between, exponent 1.
- δ² · δ³ = δ2+3 = δ5. The discount for two rounds ahead combined with the discount for three further rounds is the discount for five rounds.
- 2−1 = 1/2; 91/2 = √9 = 3; 50 = 1.
- Utility. Let the utility a person gets from x lira of money be measured by x0.88. A calculator gives 1000.88 ≈ 57.5 and 2000.88 ≈ 105.9.
- When the money doubles, by what factor does the utility grow? By the exponent rule, (2x)0.88 = 20.88 · x0.88. The ratio is 20.88 ≈ 1.84: 105.9 / 57.5 ≈ 1.84. The utility does not double; it grows by a factor of about 1.84.
The meaning of the last example is important in decision theory. A utility function with an exponent below 1 expresses in numbers the idea that "the second hundred lira does not please as much as the first hundred." Such a person, offered a sure 100 lira or an even chance of 0 or 200 lira, chooses the sure one: the sure option gives utility 57.5, while the lottery gives on average (0 + 105.9)/2 ≈ 53. This behavior is called risk aversion.
Adding exponents in a sum as well: 2² + 2³ = 4 + 8 = 12, but 25 = 32. Exponents add only when multiplying with the same base; there is no exponent rule for sums. A second common mistake is to think x0 = 0. In fact x0 = 1 (for x ≠ 0); that is why the discount on today's payoff is δ0 = 1 and today's payoff counts in full.
0.4.2The number e and the natural logarithm ln
Some bases are more useful than others. The most important is the number e ≈ 2.718. What makes e special has to do with the derivative: the slope of the function ex at every point equals its own value. This property simplifies computations greatly. In game theory, e appears in probabilistic choice rules (0.6.3) and in learning algorithms.
ex is positive for every x. The natural logarithm ln is the inverse operation of ex: ln(ex) = x, and for y > 0, eln y = y. That is, ln y answers the question "to what power must e be raised to give y?" The rules are:
- ln(a · b) = ln a + ln b,
- ln(ak) = k · ln a,
- ln 1 = 0.
Derivatives: (ex)′ = ex and (ln x)′ = 1/x.
The logarithm rules are the exponent rules read backwards. If we write a = em and b = en, then a · b = em+n; taking the ln of both sides gives ln(a · b) = m + n = ln a + ln b. The logarithm turns a product into a sum. This property also explains why algorithms that work with products of many probabilities use logarithms: instead of multiplying small numbers, working with the sum of their logarithms is both easier and numerically safe.
- ln 8. 8 = 2³. By the rule ln(ak) = k · ln a, ln 8 = 3 · ln 2 ≈ 3 · 0.693 = 2.079. Round-trip check: e2.079 ≈ 8.
- Logarithmic utility. Let the utility be u(x) = ln x. When wealth goes from 10 to 20, the gain in utility is ln 20 − ln 10 = ln(20/10) = ln 2 ≈ 0.69. When wealth goes from 20 to 40, the gain is ln 40 − ln 20 = ln 2 ≈ 0.69. Each doubling gives the same gain in utility; in the first, 10 lira was added, in the second, 20 lira.
- Marginal utility. u′(x) = 1/x: at wealth 10 the extra utility of one lira is about 0.1, at wealth 100 about 0.01. As one grows richer, the utility of an extra lira shrinks.
Figure 0.12 shows the inverse-function relationship. A function and its inverse are symmetric about the line y = x: since e0 = 1, the curve ex passes through the point (0, 1), and since ln 1 = 0, the curve ln x passes through (1, 0). The curve ex is always above the x-axis; ln x is defined only for positive x.
Believing that ln(a + b) = ln a + ln b. A numerical check shows the error: ln(2 + 6) = ln 8 ≈ 2.08, but ln 2 + ln 6 = ln 12 ≈ 2.48. It is the logarithm of a product that turns into a sum, not that of a sum. Also, ln 0 and the ln of negative numbers are undefined: ex is never zero or negative, so the question "to what power must e be raised to give 0?" has no answer.
0.4.3The product rule and the chain rule
The rules in 0.3.5 suffice for functions whose product we can first multiply out and write as a sum of terms. But not every function can be expanded like that. For nested functions such as ln(1 + 2x) or e−x, and for long products, two more rules are needed.
- Product rule: (f · g)′ = f′ · g + f · g′.
- Chain rule: [f(g(x))]′ = f′(g(x)) · g′(x). First take the derivative of the outer function, leaving the inner one as it is; then multiply by the derivative of the inner one.
The product rule can be pictured as follows: f · g is the area of a rectangle with one side f and the other g. When x increases a little, both sides grow a little. The increase in area comes from two strips: the strip added by the growth of side f (f′ · g) and the strip added by the growth of side g (f · g′). The tiny square in the corner is the product of the two small increments and is neglected.
The chain rule, in turn, is a transfer of rates. The inner function changes with x at rate g′; the outer function changes with its own input at rate f′. When x changes, the result changes at the product of these two rates. Figure 0.13 draws this transfer as a pipeline.
- Product rule. In the profit u(q) = q · (12 − q − r), f = q and g = 12 − q − r. f′ = 1, g′ = −1 (r is constant). By the rule: u′ = 1 · (12 − q − r) + q · (−1) = 12 − 2q − r. Multiplying out and then differentiating (0.3.6) gives the same result.
- Chain rule, logarithm. [ln(1 + 2x)]′: the outer function is ln, the inner function is g = 1 + 2x. The outer derivative is 1/g = 1/(1 + 2x), the inner derivative is g′ = 2. The result is 2/(1 + 2x).
- Chain rule, exponential. (e−x)′: the outer derivative is e−x (the exponential function is its own derivative), the inner derivative is (−x)′ = −1. The result is −e−x.
- Chain rule, square. [(1 − p)²]′: the outer function is squaring, with derivative 2(1 − p); the inner derivative is (1 − p)′ = −1. The result is 2(1 − p) · (−1) = −2(1 − p). Check: expanding (1 − p)² = 1 − 2p + p² gives the derivative −2 + 2p = −2(1 − p) ✓.
The chain rule is easy to check: compare the result with the one obtained by expanding the function and differentiating with known rules. This check was done in the last example. For functions that cannot be expanded (logarithm, exponential), a numerical check can be made: at x = 0 the derivative of ln(1 + 2x) is 2 by the formula; when x goes from 0 to 0.001 the function increases by ln 1.002 ≈ 0.002, so the rate of increase is about 2 ✓.
Forgetting the derivative of the inner function: writing (e−x)′ = e−x. The correct answer is −e−x; the minus sign comes from the inner derivative. There is also a common mistake with products: writing (f · g)′ = f′ · g′ is wrong. For example, (q · q)′ = (q²)′ = 2q, but f′ · g′ = 1 · 1 = 1.
0.4.4Partial derivatives
In a game the payoff depends not only on one player's choice but on everyone's. The firm's profit u(q, r) depends both on its own quantity q and on the opponent's quantity r. For such a function of two variables the question "what is the derivative?" is ambiguous: which variable is changing? Since in a game each player can choose only her own variable, the right question is: "while the other variable stays put, how does my payoff change when my variable changes?"
The partial derivative ∂u/∂q of u(q, r) with respect to q is the derivative taken with respect to q alone, holding r like a fixed number. ∂u/∂r is taken in the same way with q held fixed. The symbol ∂ is read "partial."
The partial derivative requires no new rule. When taking ∂u/∂q, wherever r appears we act as if 4, 7, or some other constant had been written there; all the rules we know apply unchanged. In game theory each player sets the partial derivative with respect to her own variable equal to zero. This gives one equation per player, that is, a best-response formula. When these equations are solved together, we find the point where everybody is best-responding at the same time.
Two firms: the first firm's profit is u1(q, r) = q(12 − q − r) and the second's is u2(q, r) = r(12 − q − r).
- Expand the first profit: u1 = 12q − q² − qr.
- Hold r fixed: ∂u1/∂q = 12 − 2q − r. (12q contributes 12, q² contributes 2q, qr contributes r.)
- For comparison, the other partial derivative can also be taken: with q fixed, ∂u1/∂r = −q. If the opponent produces one more unit, the price falls by one and the first firm's profit falls by q.
- The second firm chooses its own variable r: u2 = 12r − qr − r² and ∂u2/∂r = 12 − q − 2r.
- Each firm sets its own partial derivative equal to zero: 12 − 2q − r = 0 and 12 − q − 2r = 0.
- Subtract the second equation from the first: (12 − 2q − r) − (12 − q − 2r) = −q + r = 0, so q = r. Substitute into the first equation: 12 − 3q = 0 ⇒ q = 4. The result is q = r = 4.
- Check: against r = 4 the first firm's best quantity is (12 − 4)/2 = 4 (0.3.6); by symmetry the same holds for the second firm. Each firm's profit is 4 · (12 − 8) = 16.
Figure 0.14 shows the geometric meaning of the partial derivative. Each value of r gives a separate curve depending on q. ∂u/∂q is the slope of the curve selected by fixing r. The more the opponent produces, the lower the curve sits and the further left its peak moves: the firm both earns less and wants to produce less. At the point q = r = 4 found in the example, each firm is at the peak of its own curve, which means neither wants to change its quantity on its own. In game theory this property is called an equilibrium.
Setting the fixed variable to zero or differentiating it as well. ∂(q · r)/∂q = r; it is not 0 (r is fixed but not zero) and it is not 1 + r (r is not differentiated). A second mistake is to differentiate with respect to the wrong variable: the first firm cannot choose r, so its condition is not ∂u1/∂r = 0 but ∂u1/∂q = 0.
0.5Probability and expected value
In games, uncertainty comes from two sources. The first is nature: dice, cards, the weather. The second is the opponent: what the opponent will play is not known for certain, and sometimes the opponent deliberately acts at random. In both cases the question that governs the decision is the same: "what do I win on average?" To answer it, we need to find probabilities by counting, update them when information arrives, and compute the average payoff, that is, the expected value. When the values are continuous (like every number between 0 and 1), an integral takes the place of the sum.
0.5.1Computing probabilities by counting
If all possible outcomes of an experiment (rolling a die, drawing a card) are equally likely, the probability of an event is a ratio of counts: the number of desired outcomes divided by the number of all outcomes. A probability is always a number between 0 and 1; 0 means "never" and 1 means "certain."
- If the outcomes are equally likely: P(event) = number of desired outcomes / number of all outcomes.
- If two events are independent (neither affects the probability of the other), the probability that both occur is the product: P(A and B) = P(A) · P(B).
- If two events cannot occur at the same time, the probability that one or the other occurs is the sum: P(A or B) = P(A) + P(B).
- Complement: the probability that an event does not occur is P(not A) = 1 − P(A).
The product rule for independence is the probability version of the counting rule in 0.2.3. When two dice are rolled, each of the 6 outcomes of the first die pairs with each of the 6 outcomes of the second to form one of 36 outcomes. So the probability that both dice show 6 is 1/36 = 1/6 · 1/6. The complement rule, in turn, is very useful for "at least one" questions: instead of counting the event "at least one 6" directly, we count "no 6 at all" and subtract from 1.
- An even number on a die. The desired outcomes are {2, 4, 6}: three outcomes. There are six outcomes in all. P = 3/6 = 1/2.
- Two heads in two coin flips. The flips are independent: 1/2 · 1/2 = 1/4. Check by counting: there are four equally likely outcomes (HH, HT, TH, TT) and only one is two heads.
- At least one 6 on two dice. Use the complement. The probability of no 6 on one die is 5/6. The two dice are independent, so no 6 at all has probability (5/6) · (5/6) = 25/36. Hence P(at least one 6) = 1 − 25/36 = 11/36.
- Check by counting. In Figure 0.15 the 36 outcomes are arranged in a table. The sixth row has 6 cells and the sixth column has 6 cells; the cell (6, 6) is in both, so it is subtracted once: 6 + 6 − 1 = 11 orange cells.
Saying 1/6 + 1/6 = 12/36 for "at least one 6 on two dice." This sum counts the outcome (6, 6) twice; the correct answer is 11/36. Probabilities add only if the events cannot occur together. "The first die is 6" and "the second die is 6" can both happen in the same roll. The same mistake grows with more dice: for six dice the addition method gives 6 · 1/6 = 1, that is, it claims a "certain at least one 6"; the correct answer is 1 − (5/6)6 ≈ 0.665.
0.5.2Probability distributions
If the outcome of an experiment is a number (the face of a die, the sum of two dice, the prize of a lottery), that number is called a random variable and is usually written with a capital letter: X. The table that gives a probability to each possible value of X is called a probability distribution.
If the values that X can take are x1, …, xk, its distribution is the list of probabilities P(X = xj). Two conditions are needed for a list to be a distribution:
- every probability is between 0 and 1: 0 ≤ P(X = xj) ≤ 1,
- the probabilities sum to 1: Σj P(X = xj) = 1.
These two conditions are used unchanged in the definition of mixed strategies (0.6.1). The probabilities a player assigns to her moves must form a distribution. Errors in computations are often caught by checking the second condition: add up the probabilities, and if the total is not 1, something is wrong.
Let X be the sum of two fair dice. The values of X run from 2 to 12.
- There are 36 equally likely outcomes (0.5.1).
- Count the pairs that give sum 7: (1, 6), (2, 5), (3, 4), (4, 3), (5, 2), (6, 1). There are six pairs: P(X = 7) = 6/36 = 1/6.
- Sum 2 occurs only with (1, 1): P(X = 2) = 1/36. Sum 12 also occurs only with (6, 6).
- In general, as the sum goes from 2 to 7 the number of pairs is 1, 2, 3, 4, 5, 6; from 7 to 12 it is 5, 4, 3, 2, 1.
- Check: 1 + 2 + 3 + 4 + 5 + 6 + 5 + 4 + 3 + 2 + 1 = 36; the total probability is 36/36 = 1 ✓.
Treating every sum as equally likely: "there are 11 different sums, each 1/11." What is equally likely is the outcomes (the pairs of dice), not the sums. Sum 7 is obtained with six different pairs; sum 2 with a single pair. The bars of different heights in Figure 0.16 are the picture of this. The counting rule for probability (0.5.1) applies only to equally likely outcomes; one must first determine what the equally likely outcomes are.
0.5.3Conditional probability
A player gains information during the game: she sees one of the opponent's moves, receives a signal, has a card revealed. This information changes the probabilities. For example, once we learn that the card drawn from a deck is red, the probability that it is a heart rises from 1/4 to 1/2. The probability updated with the new information is called a conditional probability.
With P(B) > 0, the probability of A given that event B is known to have occurred is defined by
P(A | B) = P(A ∩ B) / P(B)
A ∩ B means that both A and B occur. P(A | B) is read "the probability of A given B."
The meaning of the formula is this: once we learn that B has occurred, the outcomes outside B are now impossible. Only the outcomes inside B remain, and in this narrowed world we look for the share of A. The denominator P(B) is the size of the new world; the numerator P(A ∩ B) is the space that A occupies in this world. In the card example there are 26 red cards, and 13 of them are hearts: P(heart | red) = (13/52)/(26/52) = 1/2.
A traffic light at an intersection picks one of three situations, each with probability 1/3: (Ayşe Stop, Bora Stop), (Ayşe Stop, Bora Go), (Ayşe Go, Bora Stop). It shows each driver only her or his own signal. Ayşe sees "Stop." What is the probability that Bora has seen "Go"?
- Let B = "Ayşe sees Stop." This event occurs in the first two situations: P(B) = 1/3 + 1/3 = 2/3.
- Let A = "Bora sees Go." A ∩ B is only the second situation: P(A ∩ B) = 1/3.
- Apply the definition: P(Bora Go | Ayşe Stop) = (1/3)/(2/3) = 1/2.
- Interpretation: when Ayşe sees "Stop," in one of the two remaining equally likely situations Bora goes and in the other he stops. For Ayşe, the probability that Bora goes has risen from 1/3 to 1/2. Figure 0.17 shows this narrowing with boxes.
This example is the basis of an important idea in game theory. The light is a coordination device that prevents the drivers from colliding. Each driver decides for herself whether to follow the light's recommendation. When Ayşe sees "Stop," she knows that Bora goes half the time; with this information she can compute whether stopping is a good choice for her. Arrangements of this kind, in which the recommendations are in everyone's interest to follow, are called correlated equilibria. The whole calculation rests on conditional probability.
Ignoring the information ("Bora sees Go: 1/3") or mixing up the direction of the condition. P(A | B) and P(B | A) are generally different. In the example P(Ayşe Stop | Bora Go) = 1: if Bora goes, Ayşe certainly stops. But P(Bora Go | Ayşe Stop) = 1/2. The event that is known (right of the bar) and the event that is asked about (left of the bar) must always be written separately.
0.5.4Bayes' rule
In games such as poker, players do not know the opponent's "type": is the opponent aggressive or calm? But they do see the opponent's moves. A large bet is a signal that the opponent is aggressive; how strong a signal it is can be found by calculation. The rule for updating a belief after an observation is Bayes' rule.
The belief P(A) before the observation is called the prior, and the belief P(A | B) after observing B is called the posterior. If P(B) > 0, then
P(A | B) = P(B | A) · P(A) / P(B)
The denominator is often computed from two parts: P(B) = P(B | A) · P(A) + P(B | not A) · P(not A).
The definition of conditional probability is written in both directions. P(A | B) = P(A ∩ B)/P(B) and P(B | A) = P(A ∩ B)/P(A). Multiplying the second equality by P(A) gives P(A ∩ B) = P(B | A) · P(A). Putting this into the numerator of the first equality gives the rule. For the denominator the following observation suffices: B occurs either together with A or without A; these two cases cannot happen at once. So P(B) = P(A ∩ B) + P(not A ∩ B), and each part is written with the same product rule. □
Twenty percent of players are aggressive. An aggressive player makes a large bet with probability 0.8, a calm player with probability 0.2. A player has been seen making a large bet. What is the probability that this player is aggressive?
- Prior: P(aggressive) = 0.2; hence P(calm) = 0.8.
- Probabilities of the observation: P(big | aggressive) = 0.8, P(big | calm) = 0.2.
- Denominator: P(big) = 0.8 · 0.2 + 0.2 · 0.8 = 0.16 + 0.16 = 0.32.
- Numerator: P(big | aggressive) · P(aggressive) = 0.8 · 0.2 = 0.16.
- Posterior: P(aggressive | big) = 0.16 / 0.32 = 1/2.
- Check by counting. Imagine 100 players (Figure 0.18). 20 are aggressive, and 0.8 · 20 = 16 of them make a large bet. 80 are calm, and 0.2 · 80 = 16 of them make a large bet. Of the 16 + 16 = 32 people who make a large bet, 16 are aggressive: 16/32 = 1/2 ✓.
The result is surprising at first: although aggressive players make a large bet 80% of the time, the probability that someone who makes a large bet is aggressive is only 50%. The reason is the prior. Calm players are four times as numerous. Even though each of them rarely makes a large bet, there are so many of them that half of the large bets come from them. The observation has raised the belief from 0.2 to 0.5; this is a strong update, but it does not give certainty.
The count-tree method is the safest way to do Bayes computations. Instead of probabilities, imagine a group of 100 or 1000 people, find the number of people on each branch by multiplication, and at the end count only the branches consistent with the observation. Each term in the formula corresponds to a branch in the tree: the numerator is the "aggressive" branch consistent with the observation; the denominator is all the branches consistent with the observation.
Forgetting the prior: "Aggressive players make a large bet 80% of the time, so this player is 80% likely to be aggressive." This sentence confuses P(big | aggressive) with P(aggressive | big) (the direction error of 0.5.3). Because calm players are four times as numerous, their rare large bets also make up half of the total. If the prior is skipped, rare types always look more common than they are.
0.5.5Expected value
The most basic tool for deciding under uncertainty is the expected value. If a game were played many times, what would be won on average per round? The answer is a weighted average in which each possible outcome is counted in proportion to its own probability.
Let X be a number whose value depends on chance. The expected value of X is obtained by multiplying each value x it can take by its probability and adding:
E[X] = Σx x · P(X = x)
Why the expected value is a "long-run average" can be seen as follows. Roll a fair die 600 times. Each face comes up about 100 times. The total of all the rolls is about 1 · 100 + 2 · 100 + … + 6 · 100 = 2100; the average per roll is 2100/600 = 3.5. This computation is nothing other than multiplying each value by its frequency, that is, its probability, and adding.
The expected value has two useful properties. First, multiplying by a constant and adding a constant pass straight through to the expected value: E[aX + b] = a · E[X] + b. If the prizes of a game double, the expected prize doubles; if an entry fee is deducted, the expected net gain falls by that amount. Second, the expected value of a sum is the sum of the expected values: the expected value of the sum of two dice is 3.5 + 3.5 = 7. This second property holds even if the dice are not independent.
Let X be the face shown by a fair die.
- The values are 1, 2, 3, 4, 5, 6; each has probability 1/6 (Figure 0.19).
- Multiply each value by its probability and add: E[X] = 1 · (1/6) + 2 · (1/6) + 3 · (1/6) + 4 · (1/6) + 5 · (1/6) + 6 · (1/6).
- Take the common factor 1/6 outside: E[X] = (1 + 2 + 3 + 4 + 5 + 6)/6 = 21/6 = 3.5.
In game theory the expected value is everywhere. A player computes the expected payoff of each of her moves against the opponent's probabilistic behavior and chooses the largest (0.6.2). A mechanism designer computes the participants' expected payments. All of these computations apply the same formula: value times probability, then add.
Taking the expected value to be "the most likely outcome" or "the outcome that will certainly occur." A die never shows 3.5; 3.5 is only the average of many rolls. A lottery whose payoff is 0 or 100 can have expected value 30 (if it pays 100 with probability 0.3), but the lottery never pays 30. The expected value describes not the result of a single play but the average of repetition.
0.5.6Code trace: the expected value of a lottery
A lottery ticket wins 100 TL with probability 0.05, 20 TL with probability 0.25, and nothing with probability 0.70. The ticket costs 12 TL. The code below is the same as the code in the slides and applies the expected-value formula with a loop.
prize = [100, 20, 0] # TL
prob = [0.05, 0.25, 0.70]
E = 0
for i in range(3):
E = E + prize[i] * prob[i]
print("E =", E)
print("net =", E - 12) # ticket 12 TLThe structure of the code is a one-to-one counterpart of the Σ sum:
- The lists
prizeandprobare matched by index: index 0 is the largest prize (100 TL, 0.05). E = 0: the accumulator starts at zero. It is the "nothing added yet" state of Σ.- At each step of the loop one term,
prize[i] * prob[i], is added to the accumulator. - The last two lines print the expected prize and the net expected gain after the ticket price is deducted.
| i | prize[i] | prob[i] | Term | E (after the step) |
|---|---|---|---|---|
| – | – | – | – | 0 |
| 0 | 100 | 0.05 | 5 | 5 |
| 1 | 20 | 0.25 | 5 | 10 |
| 2 | 0 | 0.70 | 0 | 10 |
Table 0.2 shows the term added at each step and the new value of the accumulator, and Figure 0.20 shows the final state. The notable step of the trace is the third term. The prize of a blank ticket is 0, and 0 · 0.70 = 0 does not change the accumulator. But this row is not superfluous: its probability is 0.70, and it must be counted for the distribution to sum to 1. Checking the sum of the probabilities shows that no outcome has been forgotten.
The expected prize of one ticket is 10 TL. Since the ticket costs 12 TL, the net expected gain is 10 − 12 = −2 TL. Someone who plays many times loses on average 2 TL per ticket. The same result also follows from the linearity of the expected value: the net gain is X − 12 and E[X − 12] = E[X] − 12 = −2. When the code is run it prints two lines: E = 10.0 and net = -2.0. Python writes decimal numbers with a point (10.0). In this example the result comes out exact; with other probabilities a number very close to it, such as 9.999999999999998, may appear because of floating-point rounding. This does not mean the computation is wrong; it shows that some decimal numbers cannot be represented exactly in binary.
0.5.7Is this dice game worth playing?
The most direct use of expected value is to decide whether a game is worth entering. The computation can be organized neatly in a table; the question of a "fair price" is answered with an equation in one unknown.
A game at a fair: you pay 10 TL and a die is rolled. If it shows 6 you receive 40 TL, if it shows 5 you receive 10 TL; on any other number you receive nothing.
- The possible prizes and their probabilities are written in a table (Table 0.3). Since 1, 2, 3, and 4 give the same prize (0), they are merged into one row; their probabilities add: 4/6.
- For each row compute x · P(x): 40/6, 10/6, and 0.
- The expected prize is 50/6 ≈ 8.33 TL.
- Since the entry fee is 10 TL, the net expected gain is 50/6 − 10 = −10/6 ≈ −1.67 TL. If risk is ignored, playing is not profitable.
| Die | Prize x | P(x) | x · P(x) |
|---|---|---|---|
| 6 | 40 | 1/6 | 40/6 |
| 5 | 10 | 1/6 | 10/6 |
| 1, 2, 3, 4 | 0 | 4/6 | 0 |
| Total | 6/6 = 1 | 50/6 ≈ 8.33 |
What would make the game fair? A game is called fair if its net expected gain is zero. Let the prize for 6 be an unknown y, with the other prizes unchanged. The expected prize is y/6 + 10/6 = (y + 10)/6. For fairness this must equal the entry fee:
(y + 10)/6 = 10 ⇒ y + 10 = 60 ⇒ y = 50
If the prize for 6 were 50 TL, the game would be fair. The same question can be asked another way: if the prizes stay the same, what should the entry fee be? The answer is the expected prize itself, about 8.33 TL. This is an equation in one unknown; equations in two unknowns are treated in 0.9.2.
Deciding with "my chance of winning is 2/6, not bad." The probability of winning alone is not enough; the size of the prizes and the entry fee count as well. If the prize for 6 were 1000 TL, the game would be very profitable with the same 2/6 chance; if it were 11 TL, it would be very costly. The decision is made by the net expected value. (A risk-averse person may reject even a game with positive net expected value; this preference is modeled with utility functions.)
0.5.8The continuous uniform distribution U[0, 1]
So far the random variables have taken one of a few values. Some quantities, however, can be any number in an interval: the value a buyer places on a good, a bid, a waiting time. The most common assumption in auction models is that the opponents' values are spread "equally likely" between 0 and 1. This distribution is called the uniform distribution.
The notation X ~ U[0, 1] is read "X is uniformly distributed between 0 and 1": every value in this interval is equally likely. Its graph is a rectangle of height 1; this height is called the probability density: f(x) = 1 (0 ≤ x ≤ 1). Probability is the area under the density:
P(a ≤ X ≤ b) = b − a and in particular P(X ≤ x) = x.
In a continuous distribution the probability of a single point is zero. This is odd at first: the value 0.5 may well occur, so how can its probability be zero? The explanation is that the interval contains infinitely many values. If each were given a positive probability, the total would be infinite. So probability is given not to points but to intervals; the probability of an interval is its length. A point, whose length is zero, has probability zero. One consequence is that P(X ≤ 0.6) and P(X < 0.6) are the same.
In an auction the opponent's value is X ~ U[0, 1]. The opponent bids her value.
- One opponent. A bid of 0.6 wins if the opponent's value is below 0.6: P(X ≤ 0.6) = 0.6 (Figure 0.21). Area: base 0.6 × height 1.
- Two independent opponents. To beat both, two events must occur together. By independence, 0.6 · 0.6 = 0.36.
- An interval. P(0.2 ≤ X ≤ 0.5) = 0.5 − 0.2 = 0.3.
- The mean. By symmetry the mean is the middle of the interval: E[X] = 1/2. This result is also found with an integral in 0.5.9.
The effect of the product rule in the second step grows quickly with the number of opponents. The probability of beating all n independent opponents with a bid of 0.6 is 0.6n: 0.6 with 1 opponent; 0.36 with 2; about 0.078 with 5. As the number of opponents grows, a higher bid is needed to win. Many computations in auction theory rest on this simple observation.
Mistaking the height of the density (1) for a probability, or giving P(X = 0.5) a positive value. In a continuous distribution a probability is an area: base (interval) × height. The density can even exceed 1: the density of U[0, 0.5] is 2, because the area above a base of length 0.5 must be 1. A density is not a probability but "probability per unit length."
0.5.9Integrals: the area under a curve
In the uniform distribution the areas are rectangles and so are easy to compute. But in computations such as expected values we need areas under sloped or curved lines. Finding the area under a curve is called integration. The integral is the continuous version of the Σ sum.
∫ab f(x) dx is the area under the graph of f between x = a and x = b. The area is divided into thin rectangles and added; as the rectangles get thinner, the total approaches the integral. dx stands for the very small width of the rectangles.
The idea in the definition is directly connected to Σ. If the interval is divided into n equal pieces, each piece has width (b − a)/n. On each piece a rectangle is placed whose height is the value of f on that piece. The sum of the areas of the rectangles is a Σ. As n grows, the rectangles fit the curve better and the total approaches the true area. The summation sign of Σ has turned into an elongated S (∫) in the integral; this S is the initial of the Latin word "summa" (sum).
- With geometry. ∫01 x dx is the area under the line y = x between 0 and 1. This area is a triangle with base 1 and height 1: 1 · 1 / 2 = 1/2.
- With rectangles. Divide the interval into four pieces, each of width 1/4. Take the height at the middle of each piece: 1/8, 3/8, 5/8, 7/8 (Figure 0.22). The total is (1/8 + 3/8 + 5/8 + 7/8) · 1/4 = (16/8) · 1/4 = 1/2. Because the graph is a straight line, the midpoint method gives the exact result here.
- General rule. By the same triangle argument, ∫0b x dx = b · b / 2 = b²/2.
- Probability is an area. For U[0, 1], P(X ≤ b) = ∫0b 1 dx = b: a rectangle of height 1 and base b.
- Expected value is an area. E[X] = ∫01 x · 1 dx = 1/2. This is the continuous counterpart of the formula E[X] = Σ x · P(x): an integral in place of the sum, and density times a small width in place of probability.
In these notes the integral is needed only as the idea of area; techniques of integration are not required. The areas we meet are rectangles and triangles. What matters is to see that probability and expected value are areas in the continuous case.
Mistaking the integral for the height of the curve at a point. The result of ∫01 x dx is not the height at x = 1 (which is 1) but the accumulated area, 1/2. A similar mistake is forgetting to divide by 2 in the area of a triangle: for ∫02 x dx the right answer is 2 · 2 / 2 = 2, not 2 · 2 = 4. E[X] = ∫ x · f(x) dx is the continuous counterpart of E[X] = Σ x · P(x); the density factor f(x) must not be dropped.
0.5.10Expected value and tail probability
There is a second way to compute an expected value. This way is often used in revenue and payment computations in auction theory. The idea is this: instead of looking at the values of X directly, look at the probability that X exceeds each threshold.
P(X > t) is the probability that X exceeds the threshold t. It is called the tail probability. If X ≥ 0, the expected value is the area under the tail-probability curve:
E[X] = ∫0∞ P(X > t) dt
The sum form, for X with values 0, 1, 2, …: E[X] = P(X ≥ 1) + P(X ≥ 2) + P(X ≥ 3) + …
Why the sum form is correct can be seen by counting. Consider an outcome with X = 3. This outcome belongs to all three of the events "X ≥ 1," "X ≥ 2," and "X ≥ 3," but not to "X ≥ 4." In the sum of the tails this outcome is counted exactly three times, that is, as many times as its own value. In general, every outcome with value x is counted x times in the tail sum. So the sum of the tails equals Σ x · P(X = x), the expected value. The integral form is the continuous version of the same idea.
- Uniform distribution. For X ~ U[0, 1] and 0 ≤ t ≤ 1, P(X > t) = 1 − t; for t > 1 it is 0.
- The tail curve is a line descending from (0, 1) to (1, 0) (Figure 0.23). The area under it is a triangle with base 1 and height 1: E[X] = ∫01 (1 − t) dt = 1/2 ✓. This agrees with the result in 0.5.9.
- Die. P(X ≥ 1) = 6/6, P(X ≥ 2) = 5/6, …, P(X ≥ 6) = 1/6.
- Sum: (6 + 5 + 4 + 3 + 2 + 1)/6 = 21/6 = 3.5 ✓. This also agrees with the result in 0.5.5.
Why is the tail formula needed? In some problems the distribution of X is known not directly but in the form of threshold probabilities. For example, the probability of exceeding the highest value among two opponents is easily found with the product rule (0.5.8); the shortest way from this probability to the expected value is the tail formula.
Mistaking the area under the density for the expected value. For U[0, 1] the area under the density is 1 (total probability); E[X] = 1/2 is the area under the curve P(X > t). The two curves are different. Also, the formula is valid only for X ≥ 0; for a variable that can take negative values, an additional term is needed.
0.6Mixed strategies
In Rock-Paper-Scissors, being predictable loses. Someone who always plays Rock loses every round once the opponent notices. The remedy is to leave the choice of move to chance. This idea combines probability with game theory: the player now chooses not a move but a probability distribution over moves. When the opponent plays this way, each move is evaluated by its expected payoff. A soft rule that turns values into probabilities (softmax) can then take the place of the sharp argmax choice.
0.6.1The idea of a mixed strategy
A player makes a single move each round. But before choosing it she can roll a die or flip a coin and let the result decide her move. The opponent then cannot know in advance which move the player will make; at most he can learn with what probabilities she plays.
A mixed strategy is a probability distribution that a player places over her own actions. In Rock-Paper-Scissors a mixed strategy is written with three numbers: (pR, pP, pS); each number is between 0 and 1 and they sum to 1.
Playing a single action with certainty (a distribution with one probability equal to 1 and the others 0) is called a pure strategy. The set of actions given positive probability is called the support of the strategy.
A mixed strategy adds no new move; it combines the existing moves with a randomizing device. Every pure strategy is a special case of a mixed strategy: (1, 0, 0) means "always Rock." Mixed strategies thus form a larger set that includes the pure strategies as well.
- An even mixture with a die. Roll a die: 1–2 gives Rock, 3–4 gives Paper, 5–6 gives Scissors. Each move corresponds to two of the six outcomes: (2/6, 2/6, 2/6) = (1/3, 1/3, 1/3).
- A biased mixture with two coins. Flip a coin; if it shows heads, play Rock. If it shows tails, flip a second coin; heads gives Paper, tails gives Scissors. The probability of Rock is 1/2. Paper requires two independent events (tails, then heads): 1/2 · 1/2 = 1/4. Scissors is likewise 1/4. The result is (1/2, 1/4, 1/4); the total is 1/2 + 1/4 + 1/4 = 1 ✓.
- A pure strategy. "Always Rock" is the mixed strategy (1, 0, 0). Its support is only {Rock}.
The strip picture in Figure 0.24 also gives a way to carry out a mixed strategy. Draw a uniform random number between 0 and 1 (0.5.8) and see which piece of the strip it falls in. In the biased mixture, play Rock if the number is below 0.5, Paper if it is between 0.5 and 0.75, and Scissors if it is above 0.75. Since the lengths of the pieces equal the probabilities, each move is chosen with the right probability. Computer programs implement mixed strategies in exactly this way.
Thinking a mixed strategy means "taking turns" (Rock, Paper, Scissors, Rock, …). In this pattern each move appears with frequency 1/3 in the long run, but the pattern is predictable: an opponent who knows that Paper follows Rock plays Scissors and wins every round. In a mixed strategy a single pure move is played each round; which one is chosen is drawn anew in every round, independently of the earlier ones.
0.6.2Expected payoff against a mixed strategy
If the opponent plays a mixed strategy, the payoff of a move is not certain; it depends on chance. So each move is evaluated by its expected payoff under the opponent's probabilities. The computation is a direct application of the expected-value formula in 0.5.5: each number in the player's row of the payoff matrix is multiplied by the probability that the opponent plays the corresponding column, and the products are added.
Bora plays (1/2 Rock, 1/4 Paper, 1/4 Scissors). We look for the expected payoff of each of Ayşe's pure moves.
- Ayşe plays Rock. Ayşe gets 0 if Bora plays Rock, −1 if Paper, +1 if Scissors. Expected: 0 · 1/2 + (−1) · 1/4 + 1 · 1/4 = 0.
- Ayşe plays Paper. +1 against Rock, 0 against Paper, −1 against Scissors. Expected: 1/2 + 0 − 1/4 = 1/4.
- Ayşe plays Scissors. −1 against Rock, +1 against Paper, 0 against Scissors. Expected: −1/2 + 1/4 + 0 = −1/4.
- Decision. argmax{0, 1/4, −1/4} = Paper. Against an opponent who favors Rock, Paper earns on average 1/4 point per round.
| Ayşe ↓ / Bora → | Rock (1/2) | Paper (1/4) | Scissors (1/4) | Expected payoff |
|---|---|---|---|---|
| Rock | 0 | −1 | +1 | 0 − 1/4 + 1/4 = 0 |
| Paper | +1 | 0 | −1 | 1/2 + 0 − 1/4 = 1/4 |
| Scissors | −1 | +1 | 0 | −1/2 + 1/4 + 0 = −1/4 |
This two-step computation, first the expected value of each row and then the argmax of these, is the most basic computation in game theory. The result is called the best response (0.8). Table 0.4 is a tidy way of writing this computation: the last column shows the expected value of each row, and the green cell shows the best response.
Ayşe can also mix. If Ayşe plays (xR, xP, xS), her expected payoff is the average of the row expectations weighted by these probabilities. For example, if Ayşe plays (1/3, 1/3, 1/3), her payoff is 1/3 · 0 + 1/3 · 1/4 + 1/3 · (−1/4) = 0; this is worse than pure Paper. The expected payoff of a mixture is the average of the expected payoffs of the mixed moves, and therefore cannot exceed the payoff of the best pure move. This observation is taken up again in matrix language in 0.7.3.
Looking only at the opponent's most frequent move ("Bora plays Rock most often, so Paper"). If Bora played (0.4 Rock, 0.25 Paper, 0.35 Scissors), Paper, which beats Rock, would bring 0.4 − 0.35 = 0.05. Rock brings −0.25 + 0.35 = 0.10; Scissors is −0.4 + 0.25 = −0.15. The best move is Rock, because Scissors is also played with high probability and Rock beats Scissors. No decision should be made without computing the expected value of every row.
0.6.3Exponential weights: logit and softmax
Choosing the best (argmax) once the expected payoffs have been computed is a sharp rule: even a small difference changes the choice completely. Real people and learning algorithms often behave more softly: they choose the good option more often and the bad option more rarely, but never rule the bad one out entirely. The rule that models this behavior is called softmax.
For options with values v1, …, vk, the softmax rule gives the probabilities
P(i) = eλvi / Σj eλvj
λ ≥ 0 is the sensitivity. With two options the rule is called the logit and is written as
P(1) = 1 / (1 + e−λ(v1 − v2))
The structure of the rule is simple. The value of each option is first multiplied by λ and then used as the exponent of e. These exponentials are always positive. Finally each is divided by the total, so the results lie between 0 and 1 and sum to 1. If λ > 0, the option with the larger value gets a larger exponential and hence a larger probability.
How the two-option case comes out of softmax can be seen as follows: P(1) = eλv1/(eλv1 + eλv2). Divide the numerator and the denominator by eλv1. The numerator becomes 1; in the denominator what remains is 1 + eλv2/eλv1 = 1 + e−λ(v1 − v2) (exponent rule: ea/eb = ea−b). This formula shows plainly that the probability depends only on the difference of the values.
The two extreme cases of λ give the meaning of the rule. When λ = 0, all the exponentials are e0 = 1 and every option gets equal probability: the values are ignored completely. As λ grows, the exponential of the largest value becomes much larger than the others and the probability concentrates on the argmax (if several options share the largest value, the probability is split equally among them). Softmax is an adjustable bridge between random choice and argmax.
The expected payoffs are as in 0.6.2: Rock 0, Paper 1/4, Scissors −1/4, and λ = 4.
- The exponents λ · v: 4 · 0 = 0, 4 · 1/4 = 1, 4 · (−1/4) = −1.
- The exponentials: e0 = 1, e1 ≈ 2.718, e−1 ≈ 0.368.
- The total: 1 + 2.718 + 0.368 ≈ 4.086.
- The probabilities: 1/4.086 ≈ 0.24, 2.718/4.086 ≈ 0.67, 0.368/4.086 ≈ 0.09. The result is P ≈ (0.24, 0.67, 0.09).
- Check: 0.24 + 0.67 + 0.09 = 1 ✓. The best move, Paper, is chosen most often and the worst move, Scissors, least often; none is zero.
Figure 0.25 shows the effect of the sensitivity. If λ were raised from 4 to 40, the exponents would be 0, 10, and −10, and the probability of Paper would rise to about 0.99995: the rule would become almost argmax. Softmax is used in behavioral game theory to model "players who make small mistakes" and in machine learning to model the balance between exploration and exploitation. The steady states in which players respond to one another with softmax are called quantal response equilibria (McKelvey and Palfrey, 1995).
Dividing the values directly by their total: vi / Σ vj. Values can be zero or negative. In the example 0 + 1/4 − 1/4 = 0, which cannot be divided by, and the probability of Scissors would also come out negative. ex is used because it is always positive. Also, since ea/eb = ea−b, adding the same number to all the values does not change the probabilities: if the values were 10, 10.25, 9.75 instead of 0, 1/4, −1/4, softmax would give the same result.
0.7The payoff matrix
All the information of a two-player game fits in a single table: the rows are one player's options, the columns the other's; each cell holds the two players' payoffs in that profile. This table is called a payoff matrix. Reading a matrix correctly is the most frequently used skill in game theory. For mixed strategies the expected payoff is also written with a matrix product.
0.7.1Reading a payoff matrix
In the payoff matrix of a two-player game, the rows are chosen by the row player and the columns by the column player. The cell where the two choices meet is the outcome of the game. In the pair (a, b) in a cell, a is the payoff of the row player and b is the payoff of the column player. If a + b = 0 in every cell, the game is zero-sum.
The definition contains two separate pieces of information. The first is who chooses what: the row player chooses only the row, and the column player only the column. Neither player can choose the cell alone. The second is whom the numbers in the cell belong to: the first number to the row player, the second to the column player. This order is the same as the order in the Cartesian product (0.2.1): profile (row choice, column choice), payoff (row payoff, column payoff).
Guess the Card. Ayşe holds a red or a black card; Bora guesses the color. If Bora guesses red correctly he takes 3 chips from Ayşe, if he guesses black correctly he takes 1 chip; if he is wrong he gives Ayşe 1 chip.
- Ayşe is the row player (Red, Black); Bora is the column player (a guess of "Red" or "Black").
- (Red, Red): Ayşe held red and Bora guessed right. Ayşe gives 3, Bora gets 3: (−3, 3).
- (Black, Black): Bora guessed black correctly; Ayşe gives 1: (−1, 1).
- (Red, Black) and (Black, Red): Bora was wrong; Ayşe gets 1: (1, −1).
- In every cell a + b = 0: the game is zero-sum.
In zero-sum games the second number is always the negative of the first, so often only the row player's payoffs are written. For Guess the Card this is the matrix A = [[−3, 1], [1, −1]]: the first row is Red, the second row is Black; the first column is the guess "Red," the second column the guess "Black." This short form is used in 0.7.3.
Taking the number b to be the row player's payoff, or thinking that Ayşe alone chooses the outcome. Ayşe chooses only the row; Bora's column determines which cell is reached. The sentence "Ayşe can get at most 1, so she picks 1" is wrong: to get 1, Bora must guess wrong, and that is up to Bora.
0.7.2Practice in reading a matrix
The reading rules are reinforced with a few questions. The questions concern the Guess the Card matrix (Figure 0.26). The answer to each question also states which row or column and which number are being looked at.
- If Ayşe holds Black and Bora says "Red," who gets how many chips? Look at the cell where the Black row meets the "Red" column: (1, −1). Bora is wrong; Ayşe gets 1 chip and Bora gives 1.
- What payoffs can Bora get when Ayşe holds Black? Look at the second numbers in the Black row: −1 (if he says "Red") and 1 (if he says "Black").
- If Bora says "Red" every round, which card should Ayşe hold? Compare the first numbers in the "Red" column: Red −3, Black 1. Since 1 > −3, Black.
- What are the largest and smallest payoffs Ayşe can get in the game? All the first numbers: −3, 1, 1, −1. The largest is 1, the smallest −3.
The method of the third question is especially important: the opponent's choice is fixed (one column is selected), the player compares her own numbers (the first numbers) and picks the largest. This is the definition of the best response (0.8.1). The fourth question gives the limits of what Ayşe can experience in the game; which outcome within these limits she gets depends on Bora's choice.
0.7.3Expected payoff is a matrix–vector product
When both players play mixed strategies, to compute the expected payoff the payoff of each cell is multiplied by the probability of landing in that cell and the products are added. As games grow, this computation becomes crowded. Matrix notation splits the computation into two orderly steps and allows it to be done on a computer in a single operation.
A mixed strategy is a probability vector: x = (x1, …, xm), with every xi ≥ 0 and Σ xi = 1. Let A be the row player's m × n payoff matrix and y the column player's probability vector.
- Ay: each row of A is multiplied by y and added; each of the resulting m numbers is that row's expected payoff against y: (Ay)i = Σj Aij yj.
- xᵀAy: these row expectations are weighted by the probabilities of x and added: xᵀAy = Σi xi (Ay)i. This is the row player's expected payoff.
The symbol ᵀ indicates that x is written as a row.
These two steps are the same computation as in 0.6.2. There, the expected value of each row was found first (the last column of Table 0.4); this is Ay. Then Ayşe's mixture weighted those numbers; this is xᵀAy. The matrix notation teaches nothing new; it merely expresses the same computation, for games of any size, in the same short form.
In Guess the Card, Ayşe's payoff matrix is A = [[−3, 1], [1, −1]]. Ayşe plays x = (1/2, 1/2) and Bora plays y = (1/4, 3/4).
- First row (Red). −3 · 1/4 + 1 · 3/4 = −3/4 + 3/4 = 0.
- Second row (Black). 1 · 1/4 + (−1) · 3/4 = 1/4 − 3/4 = −1/2.
- So Ay = (0, −1/2).
- Weighting. xᵀAy = 1/2 · 0 + 1/2 · (−1/2) = −1/4. The layout of the computation is drawn in Figure 0.27.
- Interpretation. Ayşe loses on average 1/4 chip per round; Bora (zero-sum game) gains 1/4. The largest element of Ay is 0 and belongs to the Red row: if Ayşe always held Red against this y, her loss would fall to 0.
The last step of the example shows a general rule: xᵀAy is a weighted average of the elements of Ay, and a weighted average cannot exceed the largest element. So if the opponent's strategy is known, a player can do as well with a pure best response as with any mixture. The purpose of mixing is not to win more against the opponent but to prevent the opponent from exploiting us. This difference is the essence of the idea of indifference (0.9.3).
Finding Ay and stopping there, or using x and y the wrong way round. y weights the columns (Ay: the expectation of each row); x weights these row expectations. If done the other way (the rows weighted with y), the dimensions do not match or wrong numbers come out. The largest element of Ay gives the row player's best pure response to y.
0.8Best response
All the tools of the previous sections come together in a single concept: the best response. The payoff function, argmax, expected value, and matrix reading are parts of this concept. The best response is also the building block of equilibrium, one of the most basic concepts of game theory.
0.8.1Best response
The answer to "what would I do if I knew what my opponent will do?" is the best response. The question contains an assumption: the opponent's choice is known and fixed. Under this assumption the game turns into a one-person decision problem and the answer is an argmax.
When the opponent plays s2, player 1's best response is the set of strategies that maximize her own payoff:
BR1(s2) = argmaxs1 ∈ S1 u1(s1, s2)
If the opponent plays a mixed y, the expected payoff is used in place of u1; in matrix language the best pure response is the row of the largest element of Ay.
The definition has three parts. The opponent's choice is fixed: one column of the matrix is selected. Only one's own payoffs are looked at: the first numbers are read in that column. An argmax is taken: the row of the largest number is chosen. If there is a tie there is more than one best response, and all of them belong to the set.
We find Ayşe's best responses in Guess the Card.
- Bora always says "Red." The first numbers in the "Red" column: Red −3, Black 1. BR1("Red") = Black (Figure 0.28).
- Bora always says "Black." The first numbers in the "Black" column: Red 1, Black −1. BR1("Black") = Red.
- Bora mixes. Suppose Bora says "Red" with probability q = 1/2. The Red row: −3 · 1/2 + 1 · 1/2 = −1. The Black row: 1 · 1/2 + (−1) · 1/2 = 0. Since 0 > −1, the best response is Black.
- Another mixture. For y = (1/4, 3/4) we found Ay = (0, −1/2) in 0.7.3: the best response is Red.
The last two steps give an interesting observation: when Bora's mixture changed, Ayşe's best response changed too. At q = 1/2 Black is best, at q = 1/4 Red is best. Somewhere in between there must be a q at which the two moves bring the same. This value is found in 0.9.3 and is the key to how mixed strategies are computed.
Looking at the opponent's payoff (the second number) when choosing the best response. Ayşe compares only her own numbers; what Bora earns does not directly affect Ayşe's decision. Also, a best response is not fixed: it can change when the opponent changes. The sentence "Ayşe's best move is Black" is incomplete; the right form is "When Bora says 'Red,' Ayşe's best response is Black."
0.8.2Trace: best responses in a 2×2 matrix
The best responses can be marked for the whole matrix at once. The method has two passes: first mark the row player's best response in each column, then the column player's best response in each row. In the game of Table 0.5, Ayşe chooses the row (Up/Down) and Bora the column (Left/Right).
| Ayşe \ Bora | Left | Right |
|---|---|---|
| Up | (1, 2) | (3, 1) |
| Down | (2, 3) | (0, 0) |
- If Bora plays Left, Ayşe compares the first numbers in the Left column: Up 1, Down 2. 2 > 1 ⇒ Down. The 2 in the (Down, Left) cell is marked.
- If Bora plays Right: Up 3, Down 0 ⇒ Up. The 3 in the (Up, Right) cell is marked.
- If Ayşe plays Up, Bora compares the second numbers in the Up row: Left 2, Right 1 ⇒ Left. The 2 in (Up, Left) is marked.
- If Ayşe plays Down: Left 3, Right 0 ⇒ Left. The 3 in (Down, Left) is marked. For Bora, Left is better in every case.
- Result. The only cell in which both numbers are marked is (Down, Left) = (2, 3). In this cell both players play their best responses; nobody wants to change alone. The final state of the marking is shown in Figure 0.29.
The property found in the trace, that each player plays her best response to the other's choice, is called a Nash equilibrium. An equilibrium is a situation in which nobody wants to deviate alone. The marking method is the shortest way to find all the pure equilibria of a two-player matrix game: in each column mark the row player's largest number, in each row the column player's largest number; the cells with two marks are equilibria.
It is instructive to apply the method to Guess the Card. When Bora says "Red," Ayşe's best is Black; when Ayşe holds Black, Bora's best is to say "Black"; when Bora says "Black," Ayşe's best is Red; when Ayşe holds Red, Bora's best is "Red." The best responses form a cycle and no cell has two marks. Such games have no pure-strategy equilibrium; the players must mix. The probabilities of the mixture are found with the indifference equation.
Searching for the row player's best response along a row. The row player can change only her row; therefore her comparisons are made within a column, from top to bottom. The column player's comparisons are made within a row, from left to right. A second mistake is to count a cell with only one mark as an equilibrium: in (Up, Right) Ayşe's 3 is marked, but Bora wants to move to Left.
0.9Equations and indifference
In game theory the unknowns are often probabilities: with what probability should a player play a move? These questions turn into equations. Most are linear (first degree), some are quadratic. The solution of these two kinds of equations prepares the ground for the most used equation in game theory, the indifference equation. The answers to the two questions in the introduction also rest on this equation.
0.9.1Quadratic equations and the discriminant
An equation in which the square of the unknown appears is called a quadratic equation. Its graph is a parabola and the roots are the points where the parabola crosses the horizontal axis. A parabola may cross the axis at two points, touch the axis at just one point, or not meet the axis at all. A single number, the discriminant, tells which.
The discriminant of the equation ax² + bx + c = 0 (a ≠ 0) is Δ = b² − 4ac.
- If Δ > 0, there are two distinct real roots,
- if Δ = 0, a single (repeated) root,
- if Δ < 0, no real root.
The roots are found with the formula:
x = (−b ± √Δ) / (2a)
The "±" sign in the formula abbreviates two separate computations: one with +√Δ and the other with −√Δ. When Δ = 0 the two computations give the same result; when Δ < 0 the formula cannot be applied because the square root of a negative number is not a real number.
In game theory the unknown is often a probability. In that case, of the two roots of the equation only the one between 0 and 1 is meaningful. The other root is mathematically correct but cannot be a probability. This check must be made at the end of every solution.
Suppose the equation 2p² + p − 1 = 0 has been obtained for a probability p.
- Read off the coefficients: a = 2, b = 1, c = −1.
- Discriminant: Δ = 1² − 4 · 2 · (−1) = 1 + 8 = 9. Since Δ > 0 there are two roots; √Δ = 3.
- Roots: p = (−1 ± 3)/(2 · 2) = (−1 ± 3)/4. With the plus sign 2/4 = 1/2, with the minus sign −4/4 = −1.
- A probability must lie between 0 and 1: p = −1 is discarded and p = 1/2 remains (Figure 0.30).
- Check: 2 · (1/2)² + 1/2 − 1 = 2 · 1/4 + 1/2 − 1 = 1/2 + 1/2 − 1 = 0 ✓.
The other two cases of the discriminant can also be seen with examples. For p² − p + 1/4 = 0, Δ = 1 − 4 · 1 · 1/4 = 0; the single root is p = 1/(2 · 1) = 1/2, and the parabola merely touches the axis at this point. For p² + p + 1 = 0, Δ = 1 − 4 = −3 < 0; the parabola never meets the axis and the equation has no real root.
Writing b instead of −b, or dividing only √Δ by 2a. The fraction bar is under the whole of (−b ± √Δ). Missing the sign of −4ac when c is negative is also common: in the example −4 · 2 · (−1) = +8; if the sign is missed, Δ = 1 − 8 = −7 and one reaches a wrong conclusion such as "no root."
0.9.2Linear equations in two unknowns
Two equations are needed to find two unknowns. A single equation gives infinitely many solution pairs; the second equation picks one of them. The idea of the solution is to eliminate one of the unknowns: either the two equations are subtracted from each other, or one unknown is solved from one equation and substituted into the other. The remaining equation in one unknown is solved and the value found is substituted back.
In a game shop, 2 dice and 1 deck of cards cost 50 TL, and 1 die and 1 deck cost 35 TL. How much do a die and a deck cost each? Let the price of a die be z and the price of a deck d.
- The equations: (1) 2z + d = 50 and (2) z + d = 35.
- Subtract (2) from (1): (2z + d) − (z + d) = 50 − 35. On the left d − d = 0 and z = 15 remains.
- Substitute z = 15 into (2): 15 + d = 35 ⇒ d = 20.
- Check (1): 2 · 15 + 20 = 50 ✓. Check (2): 15 + d = 35 with d = 20: 15 + 20 = 35 ✓.
The typical form of these equations in game theory is this: for two probabilities x and y, one equation is "the probabilities sum to 1" and the other is a condition coming from the game. For example, if x + y = 1 and x = 2y, the second equation is substituted into the first (the substitution method): 2y + y = 1 ⇒ 3y = 1 ⇒ y = 1/3 and x = 2/3. Check: 2/3 + 1/3 = 1 ✓ and 2/3 = 2 · 1/3 ✓.
Bora plays Left with probability q and Right with probability r. Ayşe's payoffs are 3 (Left) and 0 (Right) in Up, and 1 (Left) and 2 (Right) in Down. We want Ayşe's two rows to give equal expected payoffs.
- The equations: q + r = 1 and 3q + 0 · r = 1 · q + 2r.
- The second equation simplifies: 3q − q = 2r ⇒ 2q = 2r ⇒ q = r.
- Substitute into the first: q + q = 1 ⇒ q = 1/2, r = 1/2.
- Check: Up 3 · 1/2 = 3/2; Down 1 · 1/2 + 2 · 1/2 = 3/2 ✓.
Forgetting one side or losing a sign when subtracting. In the operation (2z + d) − (z + d), the minus in front of the parenthesis applies to both terms inside: 2z + d − z − d. The right side must likewise be 50 − 35. The values found are checked in both equations; checking in only one can hide an error in the other. In probability questions, forgetting to write the equation r = 1 − q means trying to find two unknowns from a single equation.
0.9.3The idea of indifference
What can be said about the moves that a player playing a mixed strategy mixes? The answer comes from a simple argument. If a player really mixes two of her moves, that is, gives both positive probability, the two moves must give her equal expected payoffs. If one were better, the player would always play it; giving probability to the worse one would lower her payoff for nothing.
If two actions of a player give equal expected payoffs against the opponent's strategy, the player is indifferent between these two actions. The indifference principle: if a player mixes several actions with positive probability and this is a best choice, all the actions she mixes give her equal expected payoffs.
The principle has a surprising consequence. A player's indifference depends on the opponent's probabilities, not on her own. The expected payoffs of Ayşe's two moves are computed from how often Bora plays what. The condition "Ayşe is indifferent" is therefore an equation about Bora's probability. Ayşe's own probability is found from Bora's indifference condition.
In Guess the Card, let Bora say "Red" with probability q and "Black" with probability 1 − q.
- If Ayşe holds Red: E[R] = −3 · q + 1 · (1 − q) = 1 − 4q.
- If Ayşe holds Black: E[B] = 1 · q + (−1) · (1 − q) = 2q − 1.
- When q < 1/3, for example at q = 0, E[R] = 1 > E[B] = −1: Red is better.
- When q > 1/3, for example at q = 1, E[R] = −3 < E[B] = 1: Black is better.
- Only at q = 1/3 do the two lines cross and Ayşe is indifferent.
Figure 0.31 sums up the idea visually. Ayşe's best response for each q is the upper line: Red when q is small, Black when it is large. The crossing point of the two lines is the only value of q at which Ayşe can be willing to mix. The observation in 0.8.1 is explained here as well: q = 1/4 is to the left of the crossing and Red is best; q = 1/2 is to the right and Black is best.
Trying to find Ayşe's own probability from her own indifference equation. Ayşe's indifference determines Bora's value of q, because only q appears in E[R] and E[B]. Ayşe's probability p of holding Red comes from the equation that makes Bora indifferent.
0.9.4Trace: the indifference equation
The indifference equation is always set up and solved with the same four steps. In the trace below, p is the probability that Ayşe holds Red and q is the probability that Bora says "Red." The matrix used is given again in Figure 0.32.
- The unknown. Bora says "Red" with probability q and "Black" with probability 1 − q. The total is 1; no second unknown is needed.
- The expected payoff of each row. Red: E[R] = −3 · q + 1 · (1 − q) = 1 − 4q. Black: E[B] = 1 · q + (−1) · (1 − q) = 2q − 1.
- Equate and solve. 1 − 4q = 2q − 1 ⇒ 1 + 1 = 2q + 4q ⇒ 2 = 6q ⇒ q = 1/3.
- Check. E[R] = 1 − 4/3 = −1/3 and E[B] = 2/3 − 1 = −1/3 ✓. q = 1/3 lies between 0 and 1 ✓.
When Bora chooses q = 1/3, Ayşe gets the same expected payoff, −1/3, whichever card she holds.
Repeating the same four steps for Bora gives Ayşe's probability. Let Ayşe hold Red with probability p. Bora's payoffs are the negatives of Ayşe's. If Bora says "Red" he gets 3 · p + (−1) · (1 − p) = 4p − 1, and if he says "Black" he gets (−1) · p + 1 · (1 − p) = 1 − 2p. Equating: 4p − 1 = 1 − 2p ⇒ 6p = 2 ⇒ p = 1/3. Check: both sides are 1/3. In this game the two players' probabilities happen to come out the same; in general they differ.
Let us put the results together. If Ayşe holds Red with p = 1/3 and Bora says "Red" with q = 1/3, each is indifferent against the other's strategy; neither can increase her payoff by changing her strategy. Ayşe gets −1/3 per round and Bora +1/3. The game favors Bora. It also makes sense that Ayşe holds Red with probability only 1/3: if Red is caught it costs her 3 chips, so she holds it rarely. This is the mixed-strategy equilibrium of the game that was seen to have no pure equilibrium in 0.8.2.
0.9.5Back to the game: Rock-Paper-Scissors
The two questions in the introduction can now be answered. Both are computations of expected payoff and best response.
Is there a way of playing that cannot be beaten? Yes: (1/3, 1/3, 1/3). Whatever the opponent plays, the expected payoff is 0. For example, if the opponent plays Paper: Rock gets −1, Paper 0, Scissors +1, and the expected payoff is 1/3 · (−1) + 1/3 · 0 + 1/3 · (+1) = 0. When the opponent plays Rock or Scissors the same computation also gives 0; if the opponent mixes, the result is the average of these zeros, again 0. From the point of view of indifference, the even mixture equalizes the expected payoff of the opponent's three moves. Nothing is left for the opponent to exploit.
What does someone who always plays Rock lose? The opponent's best response is always Paper, and she wins every round: −1 per round. A milder bias also loses. Against someone who plays (1/2, 1/4, 1/4), the expected payoff of each of the opponent's moves is computed: Paper 1/2 · 1 + 1/4 · 0 + 1/4 · (−1) = 1/4, Rock 0 + 1/4 · (−1) + 1/4 · 1 = 0, Scissors 1/2 · (−1) + 1/4 · 1 + 0 = −1/4. The opponent plays Paper and the biased player gets −1/4 per round.
| Player's mixture (R, P, S) | Opponent's best response | Player's expected payoff |
|---|---|---|
| (1, 0, 0): always Rock | Paper | −1 |
| (1/2, 1/4, 1/4) | Paper | −1/4 |
| (1/3, 1/3, 1/3) | all equal | 0 |
Table 0.6 shows a single principle: every deviation from the even mixture loses against an opponent who notices it. In general, against someone who plays (pR, pP, pS), the opponent's Paper brings pR − pS, her Scissors pP − pR, and her Rock pS − pP. These three numbers sum to zero; so either all of them are zero (the even mixture) or at least one is positive and the opponent picks it.
How do people play? In laboratory experiments the frequency of each move comes out close to 1/3, yet successive moves are not independent: winners tend to repeat the same move and losers tend to change theirs (Wang, Xu, and Zhou, 2014). Although the long-run frequencies resemble the even mixture, the play becomes predictable because each round is not chosen independently of the previous one. An opponent who learns patterns exploits exactly this: she looks not at frequencies but at the question "what follows after the previous round?" The mixture (1/3, 1/3, 1/3) that the theory recommends is unbeatable only if it is carried out with an independent random choice in each round.
0.10Game trees and growth rates
A matrix is for games in which the players choose simultaneously. In chess, in bargaining, or in a firm's decision whether to enter a market, the players move in turn and each later player sees the earlier player's move. Such games are drawn as a tree and solved with backward induction. Because trees grow quickly, the O and Θ notation for growth rates is also needed.
0.10.1Reading a game tree
A game tree is used for sequential games:
- A node in a circle shows whose turn it is. The topmost node is called the root; the game starts there.
- The branches leaving a node are the actions that player can choose at that moment.
- The leaves at the bottom show the players' payoffs when the game ends; the numbers are written in order of moves.
In a tree, each path from the root to a leaf is one play of the game. The number of leaves is the number of possible outcomes of the game. The basic difference between a matrix and a tree is information: in a tree the later player knows which branch the earlier player chose and decides accordingly. That is why the same player can have more than one node in a tree; each node corresponds to a different history and a separate decision is made at each.
Ayşe hides or shows her card. Bora, seeing what Ayşe did, plays on or folds (Figure 0.33).
- The root belongs to Ayşe; it has two branches: Hide and Show.
- At the end of each branch there is a node of Bora's. Bora has two nodes and decides separately at each: once after Hide, once after Show.
- There are four leaves. Hide → Play: (1, 2); Hide → Fold: (3, 0); Show → Play: (0, 1); Show → Fold: (2, 3).
- For example, the path Hide → Fold reaches the leaf (3, 0): Ayşe gets 3, Bora 0.
Mixing up the order at a leaf: the first number is the payoff of the player who moves first (Ayşe) and the second is Bora's. Another is forgetting the difference from a matrix: here Bora sees Ayşe's move. The sentence "Bora plays" is incomplete; Bora may say different things after Hide and after Show.
0.10.2Backward induction
To solve a sequential game, one starts not at the root but at the leaves. The idea is this: the decision of the player who makes the last move is easy, because nobody moves after her; she merely compares her own payoffs. Once her decision is known, the previous player can decide knowing what will happen at the end of each branch. This is repeated until the root is reached.
Backward induction: start with the nodes closest to the leaves. At each node, the player whose turn it is picks, from the payoff pairs at the ends of her branches, the one that is largest for herself; the node is replaced by that pair. The process ends when the root is reached. The pair found at the root is the outcome of the game; the choices at all the nodes together give the solution of the game.
- Start: the last move. Bora's two nodes are the nodes closest to the leaves.
- After Hide, Bora compares the second numbers: Play 2, Fold 0 ⇒ Play. The value of this node becomes (1, 2).
- After Show, Bora: Play 1, Fold 3 ⇒ Fold. The value of this node becomes (2, 3).
- Root. Ayşe, knowing Bora's answers, compares the first numbers: Hide → 1, Show → 2 ⇒ Show.
- Result. The path played is Show → Fold; the payoffs are (2, 3). The full solution: Ayşe plays Show; Bora plays Play after Hide and Fold after Show (Figure 0.34).
The result may be surprising at first: the leaf (3, 0) has the largest number for Ayşe, but the game never gets there. If Ayşe plays Hide, Bora chooses not Fold but Play, because Play gives him 2 and Fold 0. Ayşe computes this in advance and chooses Show, which gives her 2 instead of 1. This is the essence of backward induction: a player looks not at her own best leaf but at the best outcome that can be reached under the others' best responses.
In the full statement of the solution, Bora's choice at every node is given, including the node that is not played. The reason is that Ayşe's decision rests on Bora's reaction at the node that is not played: her reason for rejecting Hide is that Bora would play on after Hide. This is why, in sequential games, it matters that a strategy is a complete plan saying what to do in every situation.
Starting from the root: "Ayşe sees the largest number, 3, and says Hide." This reasoning assumes that Bora will help Ayşe. The right method moves from the leaves to the root: the last move is solved first. A second mistake is to look at the wrong player's number at each node: at Bora's node the second numbers are compared, at Ayşe's node the first numbers.
0.10.3Growth rates: O and Θ
Backward induction visits each node once. For small trees this is fast; but in the tree of a game like chess the number of nodes exceeds the number of atoms in the universe. To tell whether a method can be used in practice, we look at how the number of steps grows with the size of the input. The language for this is the O and Θ notation.
- f(n) = O(g(n)): for large n, f does not exceed a constant multiple of g. Formally, there exist c > 0 and n0 such that f(n) ≤ c · g(n) for every n ≥ n0. This is an upper bound.
- f(n) = Θ(g(n)): f grows at the same rate as g; for large n it stays between constant multiples of g from below and from above: c1 · g(n) ≤ f(n) ≤ c2 · g(n).
Constant factors and slower-growing terms are dropped: 3n² + 5n = Θ(n²).
The last example can be checked against the definition. The lower bound is easy: 3n² + 5n ≥ 3n², so c1 = 3. For the upper bound we use that for n ≥ 5, 5n ≤ n · n = n²: 3n² + 5n ≤ 3n² + n² = 4n², so c2 = 4 and n0 = 5. Thus 3n² ≤ 3n² + 5n ≤ 4n² and the function is Θ(n²). The term 5n becomes insignificant next to n² for large n.
- Ordering. Common functions from slow to fast: 1 < log log n < log n < n < n log n < n² < 2n (for large n).
- With numbers. At n = 16, log₂ log₂ n = 2, log₂ n = 4, n² = 256, 2n = 65,536. When n rises to 256, log₂ n is only 8, but 2n rises to about 1077 (Table 0.7).
- A game tree. If every node has 2 branches and the depth of the tree is d, the number of leaves is 2d: the number of nodes doubles at each level. Since backward induction looks at each node once, it takes Θ(2d) steps. At d = 30 there are about 230 ≈ 109 leaves.
| n | log₂ log₂ n | log₂ n | n² | 2n |
|---|---|---|---|---|
| 16 | 2 | 4 | 256 | 65,536 |
| 256 | 3 | 8 | 65,536 | ≈ 1077 |
| 65,536 | 4 | 16 | ≈ 4.3 · 109 | astronomically large |
Table 0.7 shows why exponential growth is an obstacle. A computer doing 109 operations per second solves a binary tree of depth d = 30 in about a second; at d = 60 it needs about 260/109 ≈ 1.15 · 109 seconds, more than 36 years. Doubling the depth does not double the time but multiplies it by a billion. That is why, in algorithmic game theory, problems that can be solved in "polynomial time" (such as n² or n³) are considered easy, and problems thought to be solvable only in exponential time are considered hard.
Taking O to mean "exactly": n = O(n²) is true (it is only an upper bound), but n = Θ(n²) is false, because n cannot be bounded from below by any constant multiple of n². O and Θ describe the trend at large n; at small n, a Θ(n²) method can be faster than a Θ(n) method. For example, a method with n² steps is faster than a method with 100n steps for n < 100.
0.11Common mistakes
Most of the mistakes in this chapter come from a few common sources: mixing up the order (in a profile, in a matrix, in a tree), confusing a number with an option (max and argmax), adding probabilities where one should not, and forgetting what a player can actually choose. Table 0.8 gives the most common mistake of each topic together with the correct version.
| Topic | Mistake | Correct |
|---|---|---|
| Profile | (Rock, Paper) = (Paper, Rock) | Order matters: Ayşe first, then Bora |
| Counting | Counting order in an unordered choice (4 · 3 = 12) | C(4, 2) = 12/2! = 6 |
| Σ | (Σ xi)² = Σ xi² | Compute the terms first, then add |
| Series | 1/(1 − δ) for a sum starting tomorrow | δ/(1 − δ); in which round does the first term come? |
| argmax | "argmax = 7" | argmax is an option (B); max is a value (7) |
| Derivative | Not checking the point f′ = 0 | f″ < 0 or neighboring values; endpoints |
| Exponents and ln | 2² + 2³ = 25; ln(a + b) = ln a + ln b | Exponents add in a product; ln turns a product into a sum |
| Chain rule | (e−x)′ = e−x | Multiply by the inner derivative: −e−x |
| Partial derivative | ∂(qr)/∂q = 0 | r is fixed but not zero: r |
| Probability | At least one 6: 1/6 + 1/6 | 1 − (5/6)² = 11/36 |
| Bayes | P(A | B) = P(B | A) | The prior counts too |
| Expected value | "E = 3.5 will come up" | The long-run average; may not occur on a single roll |
| U[0, 1] | Density = probability; P(X = 0.5) > 0 | Probability is an area; that of a single point is 0 |
| Mixed strategy | Taking turns | A single random pure move each round |
| Softmax | vi / Σ vj | eλvi / Σ eλvj |
| Matrix | Writing b as the row player's payoff | (a, b): a is the row player's, b the column player's |
| Best response | Looking at the opponent's number | Fix the opponent's choice, compare one's own numbers |
| Quadratic | Dividing only √Δ by 2a | (−b ± √Δ)/(2a); the probability is in [0, 1] |
| Indifference | Finding p from Ayşe's equation | p comes from the equation that makes Bora indifferent |
| Game tree | Starting from the root | From the leaves to the root: the last move first |
| O and Θ | n = Θ(n²) | n = O(n²); O is only an upper bound |
0.12Summary
- Notation. S1 × S2 is the set of all strategy profiles; order matters in a profile. ui assigns to a profile player i's payoff (a number). The number of profiles is counted with the product rule, unordered choices with C(n, k).
- Σ, series, max, and argmax. With Σ, each term is computed first and then added. For 0 ≤ δ < 1, 1 + δ + δ² + … = 1/(1 − δ). max is a value; argmax is the option(s) attaining it; with a tie the argmax is a set.
- Derivatives. In a continuous choice the maximum is found with f′ = 0 and checked with f″ < 0. For u(q) = q(12 − q − r) the best quantity is q*(r) = max{0, (12 − r)/2}.
- Exponents, e, and ln. xa · xb = xa+b, x0 = 1. ln is the inverse of ex and turns a product into a sum; (ln x)′ = 1/x, (ex)′ = ex.
- Differentiation rules. (fg)′ = f′g + fg′; chain rule: outer derivative × inner derivative; ∂u/∂q: the other variables are held fixed. Each player sets the partial derivative with respect to her own variable equal to zero; in the two-firm example q = r = 4.
- Probability. For equally likely outcomes, count and divide; multiply the probabilities of independent events, add those of events that cannot occur together; use the complement for "at least one." P(A | B) = P(A ∩ B)/P(B); Bayes: P(A | B) = P(B | A) · P(A)/P(B).
- Expected value. E[X] = Σ x · P(x): it is a long-run average, not the result of a single trial. A decision is made by the net expected value. For X ≥ 0, E[X] = ∫ P(X > t) dt.
- Continuous distributions. In U[0, 1] a probability is an area: P(X ≤ x) = x, a single point has probability 0, E[X] = 1/2. The integral is the area under a curve, the continuous version of Σ.
- Mixed strategies. A probability distribution over actions; a single pure move is drawn at random each round. Softmax: P(i) ∝ eλvi; equal at λ = 0, approaching argmax as λ grows.
- The payoff matrix. (a, b): a is the row player's payoff and b the column player's. The expected payoff is xᵀAy; Ay is the expectation of each row.
- Best response. Fix the opponent's choice; take the argmax of one's own payoff. In a cell where both numbers are marked, both players play their best responses (Nash equilibrium).
- Equations. x = (−b ± √Δ)/(2a); the root that is a probability lies in [0, 1]. Indifference: the mixed actions give equal expected payoffs; one player's indifference determines the opponent's probability. In Guess the Card, p = q = 1/3 and Ayşe's payoff is −1/3.
- Rock-Paper-Scissors. (1/3, 1/3, 1/3) is unbeatable (expected payoff 0); always Rock loses 1 per round, and (1/2, 1/4, 1/4) loses 1/4 per round.
- Backward induction. From the leaves to the root; the player whose turn it is picks the largest of her own payoffs. In the card game the outcome is Show → Fold, (2, 3).
- O and Θ. log log n < log n < n < n log n < n² < 2n; constants and small terms are dropped. In a binary tree, backward induction takes Θ(2d) steps.
Table 0.9 matches each tool with the place where it is most used in game theory.
| Tool | What it does | Where in game theory? |
|---|---|---|
| Cartesian product | Lists all profiles | The cells of a payoff matrix |
| Payoff function | Assigns a number to a profile | The statement of every definition |
| Geometric series | An infinite discounted sum | Repeated games |
| argmax / derivative | Finds the best option | Best response |
| Partial derivative | Slope while the other variables are fixed | Equilibrium in games with continuous strategies |
| Bayes' rule | Updates a belief after an observation | Games with incomplete information |
| Expected value | Long-run average | Payoff against mixed strategies |
| U[0, 1], integral, tail | Continuous uncertainty | Auctions |
| Softmax | Turns values into soft probabilities | Behavioral models, learning |
| Indifference equation | Finds the probabilities of a mixture | Mixed-strategy equilibrium |
| Backward induction | Solves a tree from leaves to root | Sequential games |
| O and Θ | Measures growth rate | The difficulty of computing an equilibrium |
0.13Key terms
- Cartesian product
- strategy profile
- payoff function
- product rule
- binomial coefficient C(n, k)
- geometric series
- discount factor
- argmax
- derivative
- chain rule
- partial derivative
- conditional probability
- Bayes' rule
- prior
- posterior
- expected value
- expected payoff
- uniform distribution
- probability density
- integral
- tail probability
- mixed strategy
- pure strategy
- support
- probability vector
- logit function
- softmax choice
- payoff matrix
- zero-sum game
- best response
- discriminant
- indifference principle
- sequential game
- game tree
- backward induction
- big-O and Θ notation
0.14Test Yourself
Three players have 3, 3, and 2 strategies respectively. How many strategy profiles are there? If a guard can protect 3 of 5 targets, how many pure strategies does she have; if the targets were chosen "in order," how many ordered choices would be counted?
Answer
Product rule: 3 · 3 · 2 = 18 profiles. Guard: C(5, 3) = 5!/(3! · 2!) = 120/12 = 10 pure strategies. The ordered choices number 5 · 4 · 3 = 60; since each triple is counted in 3! = 6 different orders, 60/6 = 10.
A cooperation yields 4 per round and future rounds are weighted by δ = 0.75. What is the total discounted payoff starting from this round? What would it be if the payoff came only from the next round on?
Answer
Starting today: 4/(1 − 0.75) = 4/0.25 = 16. Starting tomorrow: 4 · 0.75/(1 − 0.75) = 3/0.25 = 12. The difference is today's 4: 16 − 12 = 4.
A bag holds two coins: one fair, the other a trick coin with heads on both sides. A coin is drawn at random from the bag and flipped, and it shows heads. What is the probability that the coin is the trick coin? If the same coin is flipped a second time and again shows heads, what does this probability become?
Answer
Prior P(trick) = 1/2. P(heads) = 1/2 · 1 + 1/2 · 1/2 = 3/4. Bayes: P(trick | heads) = (1 · 1/2)/(3/4) = 2/3. For two heads, the fair coin's probability is 1/4: P(two heads) = 1/2 · 1 + 1/2 · 1/4 = 5/8 and P(trick | two heads) = (1/2)/(5/8) = 4/5. By counting with 100 trials: all 50 trick-coin trials, and 12.5 of the 50 fair-coin trials, give two heads; 50/62.5 = 0.8.
A wheel pays 0 TL with probability 1/2, 6 TL with probability 1/3, and 18 TL with probability 1/6; a spin costs 6 TL. What is the net expected gain? With the other prizes unchanged, what would the 18 TL prize have to be for the game to be fair?
Answer
The probabilities sum to 1/2 + 1/3 + 1/6 = 1 ✓. E = 0 · 1/2 + 6 · 1/3 + 18 · 1/6 = 0 + 2 + 3 = 5 TL; net 5 − 6 = −1 TL. The fair prize y: 2 + y/6 = 6 ⇒ y/6 = 4 ⇒ y = 24 TL.
In a zero-sum game the payoff matrix of the row player (Ayşe) is A = [[2, −1], [−1, 1]] (rows Up, Down; columns Left, Right). If Bora plays y = (1/2, 1/2), what is Ay and which is Ayşe's best response? With what q must Bora play Left and with what p must Ayşe play Up so that both players are indifferent? What is Ayşe's expected payoff?
Answer
Ay = (2 · 1/2 − 1 · 1/2, −1 · 1/2 + 1 · 1/2) = (1/2, 0); the best response is Up. Ayşe's indifference: 2q − (1 − q) = −q + (1 − q) ⇒ 3q − 1 = 1 − 2q ⇒ q = 2/5. Bora's payoffs are −A; his indifference: Left −2p + (1 − p) = 1 − 3p, Right p − (1 − p) = 2p − 1 ⇒ 1 − 3p = 2p − 1 ⇒ p = 2/5. Ayşe's payoff is 3 · 2/5 − 1 = 1/5 (check: 1 − 2 · 2/5 = 1/5 ✓).
The price is 20 − (q + r) and the cost is zero; the firm's profit is u(q) = q(20 − q − r). If the opponent produces r = 6, what are the best quantity and the profit? In what two ways can it be shown that this point is a peak? What are the general best-response formula and ∂u/∂r?
Answer
u(q) = q(14 − q) = 14q − q²; u′(q) = 14 − 2q = 0 ⇒ q = 7, u(7) = 49. u″ = −2 < 0; neighbors u(6) = u(8) = 48 < 49. In general: ∂u/∂q = 20 − 2q − r = 0 ⇒ q*(r) = max{0, (20 − r)/2}. ∂u/∂r = −q.
Ayşe first says Left or Right; Bora sees it and responds. After Left, if Bora says a the payoffs are (2, 1), if he says b they are (0, 0); after Right, if he says c they are (3, 0), if he says d they are (1, 2) (Ayşe, Bora). What is the result of backward induction? How many leaves does a tree of depth d with 3 branches at every node have; how many for d = 10?
Answer
After Left, Bora chooses a (1 > 0) ⇒ (2, 1). After Right, Bora chooses d (2 > 0) ⇒ (1, 2). At the root Ayşe compares 2 and 1 and says Left: the outcome is (2, 1). (3, 0) is Ayşe's largest number but Bora does not choose c. The number of leaves is 3d; for d = 10, 310 = 59,049. Backward induction takes Θ(3d) steps.
The values of three moves are v = (ln 2, 0, 0) and λ = 1. What are the softmax probabilities? With two options, if v1 − v2 = 1 and λ = ln 4, what is the logit probability P(1)? If 5 is added to all the values, do these probabilities change?
Answer
The exponentials are eln 2 = 2, e0 = 1, e0 = 1; the total is 4. The probabilities are (2/4, 1/4, 1/4) = (1/2, 1/4, 1/4): the same as the biased two-coin mixture. Logit: e−λ · 1 = e−ln 4 = 1/4, P(1) = 1/(1 + 1/4) = 4/5. Adding 5 to the values multiplies every exponential by e5λ; it cancels in the numerator and denominator and the probabilities do not change.
0.15Further reading
- M. J. Osborne, An Introduction to Game Theory (2004), Chapter 17 (Mathematical appendix): a short worked summary of numbers, sets, functions, profiles, sequences, and probability, to the extent they are used in game theory.
- J. K. Blitzstein and J. Hwang, Introduction to Probability (2019), Chapters 1–5: presents counting, conditional probability, Bayes' rule, expected value, and the uniform distribution with many examples and simulations.
- E. Lehman, F. T. Leighton, and A. R. Meyer, Mathematics for Computer Science (2017): a free textbook for computer science students covering counting, sums, and asymptotic notation (O, Θ).
- Z. Wang, B. Xu, and H.-J. Zhou, "Social cycling and conditional responses in the Rock-Paper-Scissors game" (2014): a laboratory experiment showing that in Rock-Paper-Scissors people repeat after winning and switch after losing; short and readable.
0.16References
- J. K. Blitzstein, J. Hwang, Introduction to Probability, 2nd ed., CRC Press (Chapman & Hall), 2019.
- T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein, Introduction to Algorithms, 4th ed., MIT Press, 2022 (Chapter 3: asymptotic notation).
- E. Lehman, F. T. Leighton, A. R. Meyer, Mathematics for Computer Science, MIT, 2017.
- R. D. McKelvey, T. R. Palfrey, "Quantal response equilibria for normal form games", Games and Economic Behavior 10(1), 6–38, 1995.
- M. J. Osborne, An Introduction to Game Theory, Oxford University Press, 2004.
- Z. Wang, B. Xu, H.-J. Zhou, "Social cycling and conditional responses in the Rock-Paper-Scissors game", Scientific Reports 4, 5830, 2014.
Related pages: Chapter 0 slides · © Sercan Külcü. All rights reserved.