A fishing cooperative auctions one crate of its catch every morning to n restaurant buyers. Each morning every buyer's value for the crate (the most they would pay, in dollars) is a fresh random number spread evenly between 0 and top. The cooperative wonders which sealed-bid rule earns more, and simulates rounds mornings.
The draws. Create rng = random.Random(seed). For each morning in turn, draw the n values in buyer order 0, 1, ..., n-1, each as top * rng.random() (rng.uniform(0, top) gives the same numbers). Both rules use the same values each morning.
The bids. Assume the buyers bid as economic theory predicts for this setting:
- Second-price rule: each buyer bids their value v; the highest bidder wins and pays the second-highest bid.
- First-price rule: each buyer bids \frac{n-1}{n}v (shading below their value is their equilibrium strategy here); the highest bidder wins and pays their own bid.
The cooperative's revenue on a morning is what the winner pays.
Write auction_revenues(n, rounds, top, seed) that returns the tuple (first, second, theory): the average revenue per morning under the first-price rule, under the second-price rule, and the number \text{top} \cdot \frac{n-1}{n+1}, which theory says is the expected revenue of both rules.
Examples
Input: n = 2, rounds = 4, top = 100, seed = 7
Output: (25.22606219211407, 16.174332556983426, 33.333333333333336)
Explanation: the first morning's values are about 32.38 and 15.08: the first-price rule
earns 32.38 / 2 = 16.19 and the second-price rule earns 15.08. Over four mornings the
averages still differ a lot.
Input: n = 2, rounds = 10000, top = 100, seed = 1
Output: (33.31341014356199, 33.341883654980016, 33.333333333333336)
Floats are compared with a tolerance of 1e-6.
Goals
- Draw bidders' values with a stated seeded procedure, in a stated order
- Compute the seller's revenue in each round under first-price equilibrium bids and under second-price truthful bids
- Compare the average revenues with the formula for their common expected value