@@ -174,7 +174,7 @@ Now let's proceed to code.
174174``` {code-cell} ipython3
175175class ExchangeEconomy:
176176 def __init__(self,
177- Pi ,
177+ Π ,
178178 bs,
179179 es,
180180 Ws=None,
@@ -183,17 +183,17 @@ class ExchangeEconomy:
183183 Set up the environment for an exchange economy
184184
185185 Args:
186- Pis (np.array): shared matrix of substitution
186+ Π (np.array): shared matrix of substitution
187187 bs (list): all consumers' bliss points
188188 es (list): all consumers' endowments
189189 Ws (list): all consumers' wealth
190190 thres (float): a threshold set to test b >> Pi e violated
191191 """
192- n, m = Pi .shape[0], len(bs)
192+ n, m = Π .shape[0], len(bs)
193193
194194 # check non-satiation
195195 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:
197197 raise Exception('set bliss points further away')
198198
199199 if Ws == None:
@@ -202,42 +202,42 @@ class ExchangeEconomy:
202202 if sum(Ws) != 0:
203203 raise Exception('invalid wealth distribution')
204204
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
206206
207207 def competitive_equilibrium(self):
208208 """
209209 Compute the competitive equilibrium prices and allocation
210210 """
211- Pi , bs, es, Ws = self.Pi , self.bs, self.es, self.Ws
211+ Π , bs, es, Ws = self.Π , self.bs, self.es, self.Ws
212212 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(Π )
215215
216216 # aggregate
217217 b = sum(bs)
218218 e = sum(es)
219219
220220 # compute price vector with mu=1 and renormalize
221- p = Pi .T @ b - Pi .T @ Pi @ e
221+ p = Π .T @ b - Π .T @ Π @ e
222222 p = p / p[0]
223223
224224 # compute marginal utility of wealth
225- mu_s = []
225+ μ_s = []
226226 c_s = []
227227 A = p.T @ slope_dc @ p
228228
229229 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 )
233233 c_s.append(c_i)
234234
235235 for c_i in c_s:
236236 if any(c_i < 0):
237237 print('allocation: ', c_s)
238238 raise Exception('negative allocation: equilibrium does not exist')
239239
240- return p, c_s, mu_s
240+ return p, c_s, μ_s
241241```
242242
243243## Implementation
@@ -253,17 +253,17 @@ Next we use the class ``ExchangeEconomy`` defined above to study
253253Here we tudy how competitive equilibrium $p, c^1, c^2$ respond to different $b^i$ and $e^i$, $i \in \{ 1, 2\} .
254254
255255``` {code-cell} ipython3
256- Pi = np.array([[1, 0],
257- [0, 1]])
256+ Π = np.array([[1, 0],
257+ [0, 1]])
258258
259259bs = [np.array([5, 5]), # first consumer's bliss points
260260 np.array([5, 5])] # second consumer's bliss points
261261
262262es = [np.array([0, 2]), # first consumer's endowment
263263 np.array([2, 0])] # second consumer's endowment
264264
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()
267267
268268print('Competitive equilibrium price vector:', p)
269269print('Competitive equilibrium allocation:', c_s)
@@ -275,7 +275,7 @@ What happens if the first consumer likes the first good more and the second cons
275275EE.bs = [np.array([6, 5]), # first consumer's bliss points
276276 np.array([5, 6])] # second consumer's bliss points
277277
278- p, c_s, mu_s = EE.competitive_equilibrium()
278+ p, c_s, μ_s = EE.competitive_equilibrium()
279279
280280print('Competitive equilibrium price vector:', p)
281281print('Competitive equilibrium allocation:', c_s)
@@ -287,7 +287,7 @@ Let the first consumer be poorer.
287287EE.es = [np.array([0.5, 0.5]), # first consumer's endowment
288288 np.array([1, 1])] # second consumer's endowment
289289
290- p, c_s, mu_s = EE.competitive_equilibrium()
290+ p, c_s, μ_s = EE.competitive_equilibrium()
291291
292292print('Competitive equilibrium price vector:', p)
293293print('Competitive equilibrium allocation:', c_s)
@@ -302,7 +302,7 @@ EE.bs = [np.array([4, 6]), # first consumer's bliss points
302302EE.es = [np.array([0, 2]), # first consumer's endowment
303303 np.array([2, 0])] # second consumer's endowment
304304
305- p, c_s, mu_s = EE.competitive_equilibrium()
305+ p, c_s, μ_s = EE.competitive_equilibrium()
306306
307307print('Competitive equilibrium price vector:', p)
308308print('Competitive equilibrium allocation:', c_s)
@@ -318,8 +318,8 @@ es = [np.array([1, 1]), # first consumer's endowment
318318 np.array([1, 1])] # second consumer's endowment
319319
320320Ws = [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()
323323
324324print('Competitive equilibrium price vector:', p)
325325print('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
332332``` {code-cell} ipython3
333333beta = 0.95
334334
335- Pi = np.array([[1, 0],
336- [0, np.sqrt(beta)]])
335+ Π = np.array([[1, 0],
336+ [0, np.sqrt(beta)]])
337337
338338bs = [np.array([5, np.sqrt(beta) * 5])]
339339
340340es = [np.array([1, 1])]
341341
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()
344344
345345print('Competitive equilibrium price vector:', p)
346346print('Competitive equilibrium allocation:', c_s)
@@ -353,17 +353,17 @@ We use the tricks described above to interpret $c_1, c_2$ as "Arrow securities"
353353``` {code-cell} ipython3
354354prob = 0.7
355355
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)]])
358358
359359bs = [np.array([np.sqrt(prob) * 5, np.sqrt(1 - prob) * 5]),
360360 np.array([np.sqrt(prob) * 5, np.sqrt(1 - prob) * 5])]
361361
362362es = [np.array([1, 0]),
363363 np.array([0, 1])]
364364
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()
367367
368368print('Competitive equilibrium price vector:', p)
369369print('Competitive equilibrium allocation:', c_s)
0 commit comments