Algorithm Search⌘K

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
Properties
comparison baseddeterministiciterative
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 nn bidders with private values viv_i and quasilinear utility. The seller sets a reserve r≥0r \ge 0. The auction receives bids b1,…,bnb_1, \ldots, b_n 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 F1,…,FnF_1, \ldots, F_n, a strategy βi\beta_i maps values to bids, and the bidders play a Bayes-Nash equilibrium.

The algorithm

  1. FIRST-PRICE(b_1, ..., b_n, r)
  2. 1w ← NIL
  3. 2for i ← 1 to n:
  4. 3if b_i ≥ r and (w = NIL or b_i > b_w): w ← i
  5. 4if w = NIL: return NIL, 0 ▷ no bid reaches the reserve
  6. 5return 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 F(v)=vaF(v) = v^a on [0,1][0, 1], which is β(v)=a(n−1)a(n−1)+1v\beta(v) = \frac{a(n-1)}{a(n-1)+1} v, 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 (10,7,3)(10, 7, 3). 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 [0,1][0, 1]. In the symmetric equilibrium each bidder bids β(v)=n−1nv\beta(v) = \frac{n-1}{n} v.

bidders nn bid at value vv bid at v=0.8v = 0.8 expected revenue
2 v/2v/2 0.4 1/31/3
3 2v/32v/3 0.533 1/21/2
5 4v/54v/5 0.64 2/32/3

With n=2n = 2 and value 0.80.8, a bid b≤1/2b \le 1/2 wins when the other value ww has w/2<bw/2 < b, with probability 2b2b. The expected utility is (0.8−b)⋅2b(0.8 - b) \cdot 2b. It is 0.320.32 at the equilibrium bid 0.40.4, and 0.300.30 at the bids 0.30.3 and 0.50.5. The expected revenue (n−1)/(n+1)(n-1)/(n+1) 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 [0,1][0, 1] and bidder 2 a value uniform on [0,2][0, 2]. The equilibrium has the inverse bid functions v1(b)=8b/(4+3b2)v_1(b) = 8b/(4 + 3b^2) and v2(b)=8b/(4−3b2)v_2(b) = 8b/(4 - 3b^2) on [0,2/3][0, 2/3]. At the value 1, the weak bidder 1 bids 2/32/3 and the strong bidder 2 bids about 0.430.43. 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 0.0830.083, and the expected welfare is about 1.06281.0628 against the optimum 13/12≈1.083313/12 \approx 1.0833.

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 vav^a. If the others bid β(t)=kk+1t\beta(t) = \frac{k}{k+1} t with k=a(n−1)k = a(n-1), a bidder of value vv who bids β(t)\beta(t) gets u(v,t)=(v−β(t))tku(v, t) = (v - \beta(t)) t^k. Its derivative in tt is ktk−1(v−t)k t^{k-1}(v - t), so the best tt is vv. Bids above β(1)\beta(1) are worse than β(1)\beta(1). So β\beta is a symmetric Bayes-Nash equilibrium.
  • Revenue. With uniform values the price is n−1n\frac{n-1}{n} times the highest value, whose mean is nn+1\frac{n}{n+1}, so the expected revenue is n−1n+1\frac{n-1}{n+1}.

The general symmetric equilibrium is β(v)=E[Y1∣Y1<v]\beta(v) = \mathbb{E}[Y_1 \mid Y_1 < v], with Y1Y_1 the highest of the other n−1n - 1 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 b1,…,bnb_1, \ldots, b_n and a reserve rr.

Claim 1 (the outcome). FIRST-PRICE returns the smallest index ww among the bids bi≥rb_i \ge r of largest value, and the price bwb_w. If no bid is at least rr, it returns no winner.

Proof. Invariant of the loop of line L2: before the iteration for ii, ww is the smallest index among the bids bj≥rb_j \ge r with j<ij < i of largest value, or NIL if there is none. It holds for i=1i = 1 with w=NILw = \mathrm{NIL}. In iteration ii, line L3 makes ii the leader exactly when bi≥rb_i \ge r and bib_i 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. □\square

Claim 2 (equilibrium). Let the n≥2n \ge 2 values be independent with CDF F(v)=vaF(v) = v^a on [0,1][0, 1], for a real a>0a > 0, and let k=a(n−1)k = a(n-1). With r=0r = 0, the strategy β(v)=kk+1v\beta(v) = \frac{k}{k+1} v for every bidder is a Bayes-Nash equilibrium. For uniform values (a=1a = 1) it is β(v)=n−1nv\beta(v) = \frac{n-1}{n} v.

Proof. Fix bidder ii with value vv, and let the others use β\beta. The bid β(vj)\beta(v_j) of each other bidder has no atom, and β\beta is strictly increasing with range [0,β(1)][0, \beta(1)].

  • A bid b>β(1)b > \beta(1) wins with probability 1 and gives v−b<v−β(1)v - b < v - \beta(1), so it is worse than the bid β(1)\beta(1).
  • A bid b∈[0,β(1)]b \in [0, \beta(1)] equals β(t)\beta(t) for one t∈[0,1]t \in [0, 1]. Ties have probability 0. It wins when every other value is below tt, which has probability F(t)n−1=tkF(t)^{n-1} = t^k. So its expected utility is
u(v,t)=(v−β(t)) tk=vtk−kk+1tk+1.u(v, t) = (v - \beta(t))\, t^k = v t^k - \tfrac{k}{k+1} t^{k+1}.

The derivative in tt is kvtk−1−ktk=ktk−1(v−t)k v t^{k-1} - k t^k = k t^{k-1}(v - t). It is positive for 0<t<v0 < t < v and negative for t>vt > v. So u(v,⋅)u(v, \cdot) has its maximum over [0,1][0, 1] at t=vt = v, and the bid β(v)\beta(v) is a best response, with utility u(v,v)=vk+1k+1≥0u(v, v) = \frac{v^{k+1}}{k+1} \ge 0. This holds for every vv, so β\beta is a symmetric equilibrium. □\square

The bid equals E[Y∣Y<v]\mathbb{E}[Y \mid Y < v], where YY is the largest of the other n−1n - 1 values: YY has CDF tkt^k, and ∫0vt d(tk)/vk=kk+1v\int_0^v t \, d(t^k) / v^k = \frac{k}{k+1} v. 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 a=1a = 1, the expected revenue is n−1n+1\frac{n-1}{n+1}.

Proof. The highest bid comes from the highest value Y(1)Y_{(1)}, whose CDF is tnt^n and whose mean is nn+1\frac{n}{n+1}. The price is β(Y(1))=n−1nY(1)\beta(Y_{(1)}) = \frac{n-1}{n} Y_{(1)}, with mean n−1n⋅nn+1=n−1n+1\frac{n-1}{n} \cdot \frac{n}{n+1} = \frac{n-1}{n+1}. □\square

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 nn times with at most two comparisons each. The time is Θ(n)\Theta(n) and the extra space is O(1)O(1).

Complexity

One pass over the bids with at most two comparisons per bid: Θ(n)\Theta(n) time and O(1)O(1) 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 1.9%1.9\%. In every Bayes-Nash equilibrium with independent values, the expected welfare is at least 1−1/e2≈0.8651 - 1/e^2 \approx 0.865 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 rr, a bidder with value below rr does not bid, and a bidder with value v≥rv \ge r bids E[max⁡(Y1,r)∣Y1<v]\mathbb{E}[\max(Y_1, r) \mid Y_1 < v] in the symmetric equilibrium. With uniform values and the reserve 1/21/2, 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 nn and on the prior. The bid n−1nv\frac{n-1}{n}v is right only for nn symmetric uniform bidders. With F(v)=v2F(v) = v^2 and two bidders the bid is 23v\frac{2}{3}v, not 12v\frac{1}{2}v.
  • Discrete values have no pure equilibrium. With two bidders whose values are 0 or 1 with probability 1/21/2 each, no pure strategy profile is an equilibrium: a bidder of value 1 who bids bb wants to bid just above bb. The equilibrium is mixed, with bids on [0,1/2][0, 1/2] (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.

first_price_auction.pyI0RawGitHub
# 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 1−1/e1 - 1/e of the optimal welfare, and Jin and Lu (2022) found the tight bound 1−1/e21 - 1/e^2.

References

  1. 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
  2. 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)
  3. 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)
  4. 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
  5. 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
  6. 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.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example