-
Introduction 4
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
-
Production Possibilities Frontier 4
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
-
Trade 3
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
-
Demand 4
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Lecture4.4
-
-
Supply 2
-
Lecture5.1
-
Lecture5.2
-
-
Equilibrium 4
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
-
Curve Movements 4
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
Lecture7.4
-
-
Elasticity and Revenue 5
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Lecture8.4
-
Lecture8.5
-
-
Taxes 7
-
Lecture9.1
-
Lecture9.2
-
Lecture9.3
-
Lecture9.4
-
Lecture9.5
-
Lecture9.6
-
Lecture9.7
-
-
Consumer and Producer Surplus 8
-
Lecture10.1
-
Lecture10.2
-
Lecture10.3
-
Lecture10.4
-
Lecture10.5
-
Lecture10.6
-
Lecture10.7
-
Lecture10.8
-
-
Imports and Exports 4
-
Lecture11.1
-
Lecture11.2
-
Lecture11.3
-
Lecture11.4
-
-
Tariffs 2
-
Lecture12.1
-
Lecture12.2
-
Surplus Basics Part 2
Solution
class consumer:
def __init__(self,WTP):
self.WTP = WTP
def demand(self,price):
if price<=self.WTP:
return 1
else:
return 0
def surplus(self,price):
if price<=self.WTP:
return self.WTP-price
else:
return 0
Let’s find the surplus at each price level for each person.
consumerArray = [consumer(x) for x in range(1,11)]
for price in range(1,11):
print([x.surplus(price) for x in consumerArray])
As the price level drops, new people start buying the product. When the price is equal to the person’s willingness to pay, they will buy the product but get 0 surplus out of it. The next dollar it drops, hoever, adds 1 surplus because now they get it for a dollar less. You’ll notice that as the price drops $1, everyone currently buying the good gets $1 more surplus.
And now, let’s find aggregate surplus
for price in range(0,11):
print(sum([x.surplus(price) for x in consumerArray]))
Now that we understand how surplus works from the individual consumer perspective, let’s go back to using a demand equation which simplifies all these consumers into one equation.
import sympy
p = sympy.Symbol("p")
demandEquation = 10-p
demandQ = [demandEquation.subs(p,x) for x in range(0,11)]
prices = [x for x in range(0,11)]
Something interesting is that consumer surplus is equal to the area of the triangle created by drawing a horizontal line where price is. Mathematically, it equals the same surplus that we have been getting with our previous analysis. Let’s loop through the prices with the area drawn onto the curve.
import matplotlib.pyplot as plt
import matplotlib.patches as patches
for x in prices:
plt.plot(prices,demandQ)
plt.plot(demandEquation.subs(p,x),x,"ro")
triangle1 = patches.Polygon([[demandEquation.subs(p,x),x],[0,x],[0,10]],True,color="green")
currentAxis = plt.gca()
currentAxis.add_patch(triangle1)
plt.show()
print("Consumer surplus is equal to: "+str(sum([person.surplus(x) for person in consumerArray])))
Notice that our polygon has points at the where the horizontal line crosses the y-axis, where it intersects the equilibrium point and where the demand curve intersects the y-axis.