GitHub

@@ -201,7 +201,7 @@ plt.rcParams.update({"text.usetex": True, 'font.size': 14})

201201

colors = plt.rcParams['axes.prop_cycle'].by_key()['color']

202202203203

# ensure the notebook generates the same randomness

204-

np.random.seed(1337)

204+

rng = np.random.default_rng(1337)

205205

```

206206207207

We repeat an auction with 5 bidders for 100,000 times.

@@ -212,7 +212,7 @@ The valuations of each bidder is distributed $U(0,1)$.

212212

N = 5

213213

R = 100_000

214214215-

v = np.random.uniform(0, 1, (N, R))

215+

v = rng.uniform(0, 1, (N, R))

216216217217

# BNE in first-price sealed bid

218218

@@ -431,7 +431,7 @@ v_grid = np.linspace(0.3, 1, 8)

431431

bid_analytical = b_star(v_grid, N)

432432433433

# Redraw valuations

434-

v = np.random.uniform(0, 1, (N, R))

434+

v = rng.uniform(0, 1, (N, R))

435435

bid_simulated = [evaluate_largest(ii, v) for ii in v_grid]

436436437437

fig, ax = plt.subplots(figsize=(6, 4))

@@ -453,8 +453,8 @@ Let's try an example in which the distribution of private values is a $\chi^2$ d

453453

We'll start by taking a look at a $\chi^2$ distribution with the help of the following Python code:

454454455455

```{code-cell} ipython3

456-

np.random.seed(1337)

457-

v = np.random.chisquare(df=2, size=(N * R,))

456+

rng = np.random.default_rng(1337)

457+

v = rng.chisquare(df=2, size=(N * R,))

458458459459

plt.hist(v, bins=50, edgecolor='w')

460460

plt.xlabel('Values: $v$')

@@ -464,8 +464,8 @@ plt.show()

464464

Now we'll get Python to construct a bid price function

465465466466

```{code-cell} ipython3

467-

np.random.seed(1337)

468-

v = np.random.chisquare(df=2, size=(N, R))

467+

rng = np.random.default_rng(1337)

468+

v = rng.chisquare(df=2, size=(N, R))

469469470470

# we compute the quantile of v as our grid

471471

pct_quantile = np.linspace(0, 100, 101)[1:-1]

@@ -663,8 +663,8 @@ class bid_price_solution:

663663

```

664664665665

```{code-cell} ipython3

666-

np.random.seed(1337)

667-

v = np.random.chisquare(df=2, size=(N, R))

666+

rng = np.random.default_rng(1337)

667+

v = rng.chisquare(df=2, size=(N, R))

668668669669

chi_squ_case = bid_price_solution(v)

670670

```

Read the original on github.com ↗