-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubadd.py
More file actions
67 lines (47 loc) · 1.29 KB
/
subadd.py
File metadata and controls
67 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# subadd.py
# subadditivity (single product) numerical example with plot
# python 3.7
__author__ = "Michael Wood"
__email__ = "woodjmichael@gmail.com"
__license__ = "GPL"
__version__ = "1.1"
import matplotlib.pyplot as plt
import numpy as np
import sys
# maximum quantity
L = 1500
# cost curve coefficients
a = 1
b = 1
c = 10000
# way to create different "tech" (cost curves) s.t. min(AC) is the same
k = 2
#
# Cost, Average Cost, Marginal Cost
#
# quantity
q = np.arange(1,L)
Ca = a*q**2 + b*q + c # tech A
Cb = (a/k)*q**2 + b*q + c*k # tech B
Cb2 = 2*((a/k)*(q/2)**2 + b*(q/2) + c*k) # two firms with tech B
ACa = Ca/q
ACb = Cb/q
ACb2 = Cb2/q
MCa = 2*a*q + b
#
# Plots
#
fig, ax1 = plt.subplots(figsize=(20,8.3))
ax1.plot(q[40:250], ACa[40:250], label='AC one firm tech A')
ax1.plot(q[100:600], ACb[100:600], label='AC one firm tech B')
ax1.plot(q[200:1200], ACb2[200:1200], label='AC two firms tech B')
ax1.plot(q,-10*q+1000,label='demand 1 (monopoly, econ of scale)')
ax1.plot(q,-10*q+1500,label='demand 2 (monopoly, no econ of scale)')
ax1.plot(q,-10*q+3500,label='demand 3 (no monopoly)')
ax1.plot(q,MCa,'--',label='MC one firm tech A')
ax1.set_xlim(0,L)
ax1.set_ylim(100,400)
ax1.set_xlabel('quantity')
ax1.set_ylabel('eur')
leg = ax1.legend();
plt.show()