tpemartin / 112-2-programming-for-economic-modeling

MIT License
0 stars 1 forks source link

Exercise Demand and Supply #8

Open tpemartin opened 1 year ago

12Maggie11 commented 1 year ago
import numpy as np
from numpy.linalg import inv
def qd(pd):
    qd=np.array((D@pd)+h)
    return qd
def qs(ps):
    qs=np.array((C@ps)+e)
    return qs  
def compute_equilibrium_price(D, h, C, e):
    data1=h-e
    data2=C-D
    data3=inv(data2)
    pe=data3@data1
    return pe

D=np.array([
    [-10,-5],
    [-1,-10]
])
h=np.array([
    [100],
    [50]
])
C=np.array([
    [10,5],
    [5,10]
])
e=np.array([
    [0],
    [0]
])

pe=compute_equilibrium_price(D, h, C, e)
compute_equilibrium_price(D, h, C, e), qd(pe), qs(pe)