@@ -174,7 +174,7 @@ Now let's proceed to code.
174
174
``` {code-cell} ipython3
175
175
class ExchangeEconomy:
176
176
def __init__(self,
177
- Pi ,
177
+ Π ,
178
178
bs,
179
179
es,
180
180
Ws=None,
@@ -183,17 +183,17 @@ class ExchangeEconomy:
183
183
Set up the environment for an exchange economy
184
184
185
185
Args:
186
- Pis (np.array): shared matrix of substitution
186
+ Π (np.array): shared matrix of substitution
187
187
bs (list): all consumers' bliss points
188
188
es (list): all consumers' endowments
189
189
Ws (list): all consumers' wealth
190
190
thres (float): a threshold set to test b >> Pi e violated
191
191
"""
192
- n, m = Pi .shape[0], len(bs)
192
+ n, m = Π .shape[0], len(bs)
193
193
194
194
# check non-satiation
195
195
for b, e in zip(bs, es):
196
- if np.min(b / np.max(Pi @ e)) <= thres:
196
+ if np.min(b / np.max(Π @ e)) <= thres:
197
197
raise Exception('set bliss points further away')
198
198
199
199
if Ws == None:
@@ -202,42 +202,42 @@ class ExchangeEconomy:
202
202
if sum(Ws) != 0:
203
203
raise Exception('invalid wealth distribution')
204
204
205
- self.Pi , self.bs, self.es, self.Ws, self.n, self.m = Pi , bs, es, Ws, n, m
205
+ self.Π , self.bs, self.es, self.Ws, self.n, self.m = Π , bs, es, Ws, n, m
206
206
207
207
def competitive_equilibrium(self):
208
208
"""
209
209
Compute the competitive equilibrium prices and allocation
210
210
"""
211
- Pi , bs, es, Ws = self.Pi , self.bs, self.es, self.Ws
211
+ Π , bs, es, Ws = self.Π , self.bs, self.es, self.Ws
212
212
n, m = self.n, self.m
213
- slope_dc = inv(Pi .T @ Pi )
214
- Pi_inv = inv(Pi )
213
+ slope_dc = inv(Π .T @ Π )
214
+ Π_inv = inv(Π )
215
215
216
216
# aggregate
217
217
b = sum(bs)
218
218
e = sum(es)
219
219
220
220
# compute price vector with mu=1 and renormalize
221
- p = Pi .T @ b - Pi .T @ Pi @ e
221
+ p = Π .T @ b - Π .T @ Π @ e
222
222
p = p / p[0]
223
223
224
224
# compute marginal utility of wealth
225
- mu_s = []
225
+ μ_s = []
226
226
c_s = []
227
227
A = p.T @ slope_dc @ p
228
228
229
229
for i in range(m):
230
- mu_i = (-Ws[i] + p.T @ (Pi_inv @ bs[i] - es[i])) / A
231
- c_i = Pi_inv @ bs[i] - mu_i * slope_dc @ p
232
- mu_s .append(mu_i )
230
+ μ_i = (-Ws[i] + p.T @ (Π_inv @ bs[i] - es[i])) / A
231
+ c_i = Π_inv @ bs[i] - μ_i * slope_dc @ p
232
+ μ_s .append(μ_i )
233
233
c_s.append(c_i)
234
234
235
235
for c_i in c_s:
236
236
if any(c_i < 0):
237
237
print('allocation: ', c_s)
238
238
raise Exception('negative allocation: equilibrium does not exist')
239
239
240
- return p, c_s, mu_s
240
+ return p, c_s, μ_s
241
241
```
242
242
243
243
## Implementation
@@ -253,17 +253,17 @@ Next we use the class ``ExchangeEconomy`` defined above to study
253
253
Here we tudy how competitive equilibrium $p, c^1, c^2$ respond to different $b^i$ and $e^i$, $i \in \{ 1, 2\} .
254
254
255
255
``` {code-cell} ipython3
256
- Pi = np.array([[1, 0],
257
- [0, 1]])
256
+ Π = np.array([[1, 0],
257
+ [0, 1]])
258
258
259
259
bs = [np.array([5, 5]), # first consumer's bliss points
260
260
np.array([5, 5])] # second consumer's bliss points
261
261
262
262
es = [np.array([0, 2]), # first consumer's endowment
263
263
np.array([2, 0])] # second consumer's endowment
264
264
265
- EE = ExchangeEconomy(Pi , bs, es)
266
- p, c_s, mu_s = EE.competitive_equilibrium()
265
+ EE = ExchangeEconomy(Π , bs, es)
266
+ p, c_s, μ_s = EE.competitive_equilibrium()
267
267
268
268
print('Competitive equilibrium price vector:', p)
269
269
print('Competitive equilibrium allocation:', c_s)
@@ -275,7 +275,7 @@ What happens if the first consumer likes the first good more and the second cons
275
275
EE.bs = [np.array([6, 5]), # first consumer's bliss points
276
276
np.array([5, 6])] # second consumer's bliss points
277
277
278
- p, c_s, mu_s = EE.competitive_equilibrium()
278
+ p, c_s, μ_s = EE.competitive_equilibrium()
279
279
280
280
print('Competitive equilibrium price vector:', p)
281
281
print('Competitive equilibrium allocation:', c_s)
@@ -287,7 +287,7 @@ Let the first consumer be poorer.
287
287
EE.es = [np.array([0.5, 0.5]), # first consumer's endowment
288
288
np.array([1, 1])] # second consumer's endowment
289
289
290
- p, c_s, mu_s = EE.competitive_equilibrium()
290
+ p, c_s, μ_s = EE.competitive_equilibrium()
291
291
292
292
print('Competitive equilibrium price vector:', p)
293
293
print('Competitive equilibrium allocation:', c_s)
@@ -302,7 +302,7 @@ EE.bs = [np.array([4, 6]), # first consumer's bliss points
302
302
EE.es = [np.array([0, 2]), # first consumer's endowment
303
303
np.array([2, 0])] # second consumer's endowment
304
304
305
- p, c_s, mu_s = EE.competitive_equilibrium()
305
+ p, c_s, μ_s = EE.competitive_equilibrium()
306
306
307
307
print('Competitive equilibrium price vector:', p)
308
308
print('Competitive equilibrium allocation:', c_s)
@@ -318,8 +318,8 @@ es = [np.array([1, 1]), # first consumer's endowment
318
318
np.array([1, 1])] # second consumer's endowment
319
319
320
320
Ws = [0.5, -0.5]
321
- EE_new = ExchangeEconomy(Pi , bs, es, Ws)
322
- p, c_s, mu_s = EE_new.competitive_equilibrium()
321
+ EE_new = ExchangeEconomy(Π , bs, es, Ws)
322
+ p, c_s, μ_s = EE_new.competitive_equilibrium()
323
323
324
324
print('Competitive equilibrium price vector:', p)
325
325
print('Competitive equilibrium allocation:', c_s)
@@ -332,15 +332,15 @@ Now let's use the tricks described above to study a dynamic economy, one with tw
332
332
``` {code-cell} ipython3
333
333
beta = 0.95
334
334
335
- Pi = np.array([[1, 0],
336
- [0, np.sqrt(beta)]])
335
+ Π = np.array([[1, 0],
336
+ [0, np.sqrt(beta)]])
337
337
338
338
bs = [np.array([5, np.sqrt(beta) * 5])]
339
339
340
340
es = [np.array([1, 1])]
341
341
342
- EE_DE = ExchangeEconomy(Pi , bs, es)
343
- p, c_s, mu_s = EE_DE.competitive_equilibrium()
342
+ EE_DE = ExchangeEconomy(Π , bs, es)
343
+ p, c_s, μ_s = EE_DE.competitive_equilibrium()
344
344
345
345
print('Competitive equilibrium price vector:', p)
346
346
print('Competitive equilibrium allocation:', c_s)
@@ -353,17 +353,17 @@ We use the tricks described above to interpret $c_1, c_2$ as "Arrow securities"
353
353
``` {code-cell} ipython3
354
354
prob = 0.7
355
355
356
- Pi = np.array([[np.sqrt(prob), 0],
357
- [0, np.sqrt(1 - prob)]])
356
+ Π = np.array([[np.sqrt(prob), 0],
357
+ [0, np.sqrt(1 - prob)]])
358
358
359
359
bs = [np.array([np.sqrt(prob) * 5, np.sqrt(1 - prob) * 5]),
360
360
np.array([np.sqrt(prob) * 5, np.sqrt(1 - prob) * 5])]
361
361
362
362
es = [np.array([1, 0]),
363
363
np.array([0, 1])]
364
364
365
- EE_AS = ExchangeEconomy(Pi , bs, es)
366
- p, c_s, mu_s = EE_AS.competitive_equilibrium()
365
+ EE_AS = ExchangeEconomy(Π , bs, es)
366
+ p, c_s, μ_s = EE_AS.competitive_equilibrium()
367
367
368
368
print('Competitive equilibrium price vector:', p)
369
369
print('Competitive equilibrium allocation:', c_s)
0 commit comments