Algorithmintro
First-price sealed-bid auction
Also called first-price auction, pay-your-bid auction.
Each bidder submits one sealed bid, and the highest bidder wins and pays its own bid. Bidders shade their bids below their values, and the equilibrium depends on the prior.
- Time
- O(n) worst
- Space
- O(1) extra
- Where
- n = the number of bidders
- Model
- Word RAM
- Properties
- comparison baseddeterministiciterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- William Vickrey, 1961
The first-price sealed-bid auction sells one item. Each bidder submits one sealed bid, the highest bid wins, and the winner pays its own bid. A bidder who bids its value gains nothing when it wins, so bidders bid less than their values; this is called bid shading. How much to shade depends on the number of bidders and on what each bidder believes about the others, so the auction is studied at a Bayes-Nash equilibrium in the independent private values model. It is strategically the same game as the Dutch auction, and its symmetric equilibrium is derived on the page equilibrium of the symmetric first-price auction.
In plain words
Everyone writes a price in an envelope. The highest price wins, and the winner pays what it wrote. If you write what the item is worth to you, you win nothing even when you win, because you pay all of it. So you write less. Writing less gives a better deal when you win but makes you win less often. The best amount depends on how much the others will write, which you do not know. With many rivals you shade only a little, and with few rivals you shade a lot. When everyone thinks this way and the bidders are alike, the item still goes to the one who values it most, and the seller earns on average the same as in the auction where the winner pays the second price.
The problem
One item is for sale to bidders with private values and quasilinear utility. The seller sets a reserve . The auction receives bids and must choose a winner and a price, with the rule that the winner pays its own bid and losers pay nothing. The algorithmic task is only to run this rule. The strategic question is how the bidders bid: in the model with independent values drawn from known distributions , a strategy maps values to bids, and the bidders play a Bayes-Nash equilibrium.
The algorithm
FIRST-PRICE(b_1, ..., b_n, r)- 1
w ← NIL - 2
for i ← 1 to n: - 3
if b_i ≥ r and (w = NIL or b_i > b_w): w ← i - 4
if w = NIL: return NIL, 0 ▷ no bid reaches the reserve - 5
return w, b_w ▷ w wins and pays its own bid
Ties go to the smallest index, because line L3 needs a strictly larger bid to change the leader. With values drawn from distributions without atoms, the equilibrium bids tie with probability 0, so the tie rule does not change the equilibrium.
The implementation also gives the symmetric equilibrium bid for values with CDF on , which is , and the exact expected utility of a bidder who bids as another type. The tests use them to check the equilibrium by best response.
Example
Three bidders bid . Bidder 1 wins and pays 10. If its value is 10, its utility is 0. With the bid 8 it still wins and its utility is 2. So truthful bidding is not a dominant strategy here, unlike in the Vickrey auction.
Now let the values be independent and uniform on . In the symmetric equilibrium each bidder bids .
| bidders | bid at value | bid at | expected revenue |
|---|---|---|---|
| 2 | 0.4 | ||
| 3 | 0.533 | ||
| 5 | 0.64 |
With and value , a bid wins when the other value has , with probability . The expected utility is . It is at the equilibrium bid , and at the bids and . The expected revenue is the mean of the second-highest value, the same as in the Vickrey auction.
With asymmetric bidders the first-price auction can give the item to the wrong bidder. Let bidder 1 have a value uniform on and bidder 2 a value uniform on . The equilibrium has the inverse bid functions and on . At the value 1, the weak bidder 1 bids and the strong bidder 2 bids about . The weak bidder bids more aggressively, and it wins in some cases where bidder 2 has the higher value. By numerical integration, this happens with probability about , and the expected welfare is about against the optimum .
Correctness
The proof is in proofs/correctness.md. It shows three facts.
- The outcome. The loop keeps the first highest eligible bid, and line L5 charges it its own bid.
- The equilibrium for values . If the others bid with , a bidder of value who bids gets . Its derivative in is , so the best is . Bids above are worse than . So is a symmetric Bayes-Nash equilibrium.
- Revenue. With uniform values the price is times the highest value, whose mean is , so the expected revenue is .
The general symmetric equilibrium is , with the highest of the other values (equilibrium of the symmetric first-price auction).
Proof: The first-price auction sells to the highest eligible bid at that bid, and the bid a(n-1)v/(a(n-1)+1) is a symmetric equilibrium for values with CDF v^afull
We use the pseudocode of the page, with bids and a reserve .
Claim 1 (the outcome). FIRST-PRICE returns the smallest index among the bids of largest value, and the price . If no bid is at least , it returns no winner.
Proof. Invariant of the loop of line L2: before the iteration for , is the smallest index among the bids with of largest value, or NIL if there is none. It holds for with . In iteration , line L3 makes the leader exactly when and is strictly larger than every earlier eligible bid. A bid equal to the leader's bid does not replace it, so the smallest index is kept. At the end the invariant covers all bids, and lines L4 and L5 return the claimed result.
Claim 2 (equilibrium). Let the values be independent with CDF on , for a real , and let . With , the strategy for every bidder is a Bayes-Nash equilibrium. For uniform values () it is .
Proof. Fix bidder with value , and let the others use . The bid of each other bidder has no atom, and is strictly increasing with range .
- A bid wins with probability 1 and gives , so it is worse than the bid .
- A bid equals for one . Ties have probability 0. It wins when every other value is below , which has probability . So its expected utility is
The derivative in is . It is positive for and negative for . So has its maximum over at , and the bid is a best response, with utility . This holds for every , so is a symmetric equilibrium.
The bid equals , where is the largest of the other values: has CDF , and . The general form of this fact and its uniqueness are on the page on the equilibrium of the symmetric first-price auction.
Claim 3 (revenue with uniform values). In the equilibrium of Claim 2 with , the expected revenue is .
Proof. The highest bid comes from the highest value , whose CDF is and whose mean is . The price is , with mean .
This is the mean of the second-highest value, the revenue of the Vickrey auction, as the revenue equivalence theorem says.
Cost. The loop runs times with at most two comparisons each. The time is and the extra space is .
Complexity
One pass over the bids with at most two comparisons per bid: time and extra space. The rule is as cheap as the Vickrey auction. The cost of the first-price auction is on the side of the bidders: to bid well, a bidder must know or estimate the distribution of the others' bids. For symmetric bidders the equilibrium has the closed form above. For asymmetric bidders it solves a system of differential equations with a free end point, which has a closed form only in special cases, such as the uniform example.
Properties
- Not DSIC. The best bid depends on the others' bids. A bid at or above the value never gives a positive utility.
- Efficient with symmetric bidders. The symmetric equilibrium bid is strictly increasing, so the highest value wins.
- Inefficient with asymmetric bidders. The example above has a welfare loss of about . In every Bayes-Nash equilibrium with independent values, the expected welfare is at least of the optimum, and this bound is tight (price of anarchy of first-price auctions).
- Revenue. With symmetric, independent, risk-neutral bidders, the expected revenue equals that of the Vickrey auction (revenue equivalence theorem). With risk-averse bidders the first-price auction earns more, because a risk-averse bidder shades less to win more surely (Krishna, Chapter 4).
- Credible. The winner pays its own bid, so the seller cannot raise the price by a fake bid. The second-price auction does not have this property (Akbarpour and Li 2020).
- Equivalent to the Dutch auction. A bidder in a Dutch auction chooses the price at which to stop the falling clock, learns nothing useful before that, and pays that price. So a Dutch strategy is a first-price bid.
Variants and improvements
- Reserve price. With a reserve , a bidder with value below does not bid, and a bidder with value bids in the symmetric equilibrium. With uniform values and the reserve , the first-price auction earns the same as the Vickrey auction with the same reserve, which is optimal (reserve price).
- Procurement. In a reverse auction, the lowest bid wins and is paid its bid. This is the sealed tender of public procurement.
- Many identical units. The discriminatory or pay-as-bid auction gives units to the highest bids, and each winner pays its bids. Treasury bills are sold this way in some countries.
- Advertising. Display advertising exchanges moved from second-price to first-price auctions around 2019. Then each buyer must shade its bids, and bid-shading programs learn the distribution of the highest other bid.
- All-pay. In the all-pay auction every bidder pays its bid, and the highest still wins.
When to use it
Use the first-price auction when the seller must be trusted by the bidders (the price is the winner's own bid), when the bidders are risk averse, or when a sealed one-shot sale is needed. It is the standard form for public tenders. It is a poor choice when the bidders are very unequal, because then it can give the item to the wrong bidder, and when simple bidding matters more than revenue, because bidders must guess the others' behaviour.
Pitfalls
- Bidding the value. It gives utility 0 in every case. A bidder must shade.
- The equilibrium depends on and on the prior. The bid is right only for symmetric uniform bidders. With and two bidders the bid is , not .
- Discrete values have no pure equilibrium. With two bidders whose values are 0 or 1 with probability each, no pure strategy profile is an equilibrium: a bidder of value 1 who bids wants to bid just above . The equilibrium is mixed, with bids on (see the equilibrium page).
- Asymmetry. The symmetric formula is wrong for asymmetric bidders. Each bidder's bid depends on all the distributions.
- Ties in tests. A test that runs the auction on equilibrium bids must use distributions without atoms or handle ties by the rule of line L3.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/first-price-auction/. The authors are listed in prov/VEN1KY.jsonl.
from fractions import Fraction
from typing import Sequence, Union
Number = Union[int, Fraction, float]
def first_price_auction(
bids: Sequence[Number], reserve: Number = 0
) -> tuple[int | None, Number]:
"""Run a first-price sealed-bid auction with a reserve price.
A bid can win only if it is at least the reserve. The highest such bid
wins, a tie goes to the smallest index, and the winner pays its own bid.
Return the 0-based winner and the price, or (None, 0) if no bid reaches
the reserve. Losers pay 0.
"""
winner: int | None = None # @line L1
for i in range(len(bids)): # @line L2
if bids[i] >= reserve and (winner is None or bids[i] > bids[winner]): # @line L3
winner = i # @line L3
if winner is None: # @line L4
return None, 0 # @line L4
return winner, bids[winner] # @line L5
def equilibrium_bid(value: Fraction, n: int, a: int = 1) -> Fraction:
"""Symmetric equilibrium bid for n bidders with values of CDF F(v) = v^a on [0, 1].
The bid is E[Y | Y < v] for Y the highest of the other n - 1 values, which
is a(n - 1) v / (a(n - 1) + 1). For a = 1 (uniform values) it is (n - 1) v / n.
"""
k = a * (n - 1)
return Fraction(k, k + 1) * value
def interim_utility(value: Fraction, target: Fraction, n: int, a: int = 1) -> Fraction:
"""Expected utility of a bidder of the given value who bids as type target in [0, 1].
The others bid equilibrium_bid, which is increasing, so the bid wins when
all n - 1 other values are below target, with probability target^(a(n - 1)).
"""
return (value - equilibrium_bid(target, n, a)) * target ** (a * (n - 1))
test_first_price_auction.py 95 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/first-price-auction/. The authors are listed in prov/VEN1KY.jsonl.
import random
from fractions import Fraction
from first_price_auction import equilibrium_bid, first_price_auction, interim_utility
def reference(bids, reserve=0):
eligible = [i for i in range(len(bids)) if bids[i] >= reserve]
if not eligible:
return None, 0
top = max(bids[i] for i in eligible)
return min(i for i in eligible if bids[i] == top), top
def test_example() -> None:
assert first_price_auction([10, 7, 3]) == (0, 10)
assert first_price_auction([3, 7, 10]) == (2, 10)
assert first_price_auction([10, 7, 3], reserve=8) == (0, 10)
assert first_price_auction([10, 7, 3], reserve=11) == (None, 0)
def test_edges() -> None:
assert first_price_auction([]) == (None, 0)
assert first_price_auction([5]) == (0, 5)
assert first_price_auction([7, 7, 3]) == (0, 7)
assert first_price_auction([3, 7, 7]) == (1, 7)
assert first_price_auction([2, 1], reserve=2) == (0, 2)
def test_against_reference() -> None:
rng = random.Random(1)
for _ in range(2000):
bids = [rng.randrange(0, 6) for _ in range(rng.randrange(0, 7))]
r = rng.randrange(0, 5)
assert first_price_auction(bids, r) == reference(bids, r)
def test_truthful_bidding_is_not_dominant() -> None:
# Values 10 and 7: the truthful bid 10 earns 0, the bid 8 earns 2.
w, p = first_price_auction([10, 7])
assert 10 - p == 0
w, p = first_price_auction([8, 7])
assert w == 0 and 10 - p == 2
def test_equilibrium_values() -> None:
assert equilibrium_bid(Fraction(1, 2), 2) == Fraction(1, 4)
assert equilibrium_bid(Fraction(9, 10), 3) == Fraction(3, 5)
assert equilibrium_bid(Fraction(1), 2, a=2) == Fraction(2, 3)
def test_equilibrium_is_best_response() -> None:
# Bids above equilibrium_bid(1) win for sure and are worse than bidding
# equilibrium_bid(1), so every relevant bid is equilibrium_bid(t) for some t.
grid = [Fraction(k, 60) for k in range(61)]
for n in (2, 3, 4):
for a in (1, 2):
for v in [Fraction(k, 12) for k in range(13)]:
best = interim_utility(v, v, n, a)
assert best >= 0
for t in grid:
assert interim_utility(v, t, n, a) <= best
if 0 < v:
near = min(v + Fraction(1, 60), Fraction(1))
if near != v:
assert interim_utility(v, near, n, a) < best
def test_expected_utility_by_simulation() -> None:
# Check interim_utility against the auction itself for one deviation.
rng = random.Random(2)
n, v, t = 3, Fraction(3, 4), Fraction(1, 2)
trials, total = 20000, 0.0
b0 = float(equilibrium_bid(t, n))
for _ in range(trials):
bids = [b0] + [float(equilibrium_bid(Fraction(rng.random()), n)) for _ in range(n - 1)]
w, p = first_price_auction(bids)
if w == 0:
total += float(v) - p
# Utilities are in [0, 1]; Hoeffding gives deviation above 0.02 with probability below 1e-6.
assert abs(total / trials - float(interim_utility(v, t, n))) < 0.02
def test_revenue_uniform() -> None:
rng = random.Random(3)
for n in (2, 3, 5):
trials, total = 20000, 0.0
for _ in range(trials):
values = [rng.random() for _ in range(n)]
_, p = first_price_auction([(n - 1) * x / n for x in values])
total += p
assert abs(total / trials - (n - 1) / (n + 1)) < 0.02
History
Sealed tenders in which the lowest bid wins and is paid its price are old, and governments use them for contracts and for the sale of bonds. Vickrey (1961) found the equilibrium of the first-price auction for independent uniform values and showed that its expected revenue equals that of the second-price auction. Riley and Samuelson (1981) and Myerson (1981) proved the general revenue equivalence. Maskin and Riley (2000) studied the asymmetric case and showed that the weak bidder bids more aggressively. Syrgkanis and Tardos (2013) proved that every equilibrium keeps at least of the optimal welfare, and Jin and Lu (2022) found the tight bound .
References
- William Vickrey, Counterspeculation, auctions, and competitive sealed tenders, Journal of Finance 16(1) (1961), 8-37, the equilibrium of the first-price auction with independent uniform values, and the equal expected revenue of the first-price and second-price auctions
- Vijay Krishna, Auction Theory, 2nd edition, Academic Press, 2010, Chapter 2, Section 2.3 (first-price auctions, the symmetric equilibrium and the revenue comparison) and Chapter 4 (risk-averse bidders and asymmetric bidders)
- Tim Roughgarden, Twenty Lectures on Algorithmic Game Theory, Cambridge University Press, 2016, Lecture 2, Section 2.3 (first-price auctions, why the bids are hard to reason about)
- Eric Maskin and John Riley, Asymmetric auctions, Review of Economic Studies 67(3) (2000), 413-438, first-price auctions with asymmetric bidders, in which the weak bidder bids more aggressively than the strong one and the outcome need not be efficient
- Mohammad Akbarpour and Shengwu Li, Credible auctions, a trilemma, Econometrica 88(2) (2020), 425-467, the first-price auction with a reserve is credible, so the auctioneer cannot gain by a hidden deviation, while the second-price auction is not
- Yaonan Jin and Pinyan Lu, First price auction is 1 - 1/e^2 efficient, Journal of the ACM 70(5) (2023), article 36, the tight bound on the welfare of Bayes-Nash equilibria of first-price auctions with independent values
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag VEN1KY Edit this page History Report an error Markdown