Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Commit 464975f

Browse files
mtileyjstac
authored andcommitted
Edits in geom_series.rst (#821)
* Edits in geom_series.rst - code repetition reduced and typos fixed * bracket fix in geom_series * neaten code in geom_series
1 parent 76beced commit 464975f

File tree

1 file changed

+68
-77
lines changed

1 file changed

+68
-77
lines changed

source/rst/geom_series.rst

Lines changed: 68 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Economists and financiers often define the **supply of money** as an
142142
economy-wide sum of **cash** plus **deposits**.
143143

144144
In a **fractional reserve banking system** (one in which the reserve
145-
ratio :math:`r` satisfying :math:`0 < r < 1`), **banks create money** by issuing deposits *backed* by fractional reserves plus loans that they make to their customers.
145+
ratio :math:`r` satisfies :math:`0 < r < 1`), **banks create money** by issuing deposits *backed* by fractional reserves plus loans that they make to their customers.
146146

147147
A geometric series is a key tool for understanding how banks create
148148
money (i.e., deposits) in a fractional reserve system.
@@ -177,7 +177,7 @@ bank stating promises to redeem note for gold or silver on demand).
177177
.. Dongchen: is there a way to add a little balance sheet here?
178178
.. with assets on the left side and liabilities on the right side?
179179
180-
Ecah bank :math:`i` sets its reserves to satisfy the equation
180+
Each bank :math:`i` sets its reserves to satisfy the equation
181181

182182
.. math::
183183
:label: reserves
@@ -554,15 +554,15 @@ The **present value** of the lease is
554554
where the last line uses the formula for an infinite geometric series.
555555

556556
Recall that :math:`R = 1+r` and :math:`G = 1+g` and that :math:`R > G`
557-
and :math:`r > g` and that :math:`r` and\ :math:`g` are typically small
557+
and :math:`r > g` and that :math:`r` and :math:`g` are typically small
558558
numbers, e.g., .05 or .03.
559559

560560
Use the Taylor series of :math:`\frac{1}{1+r}` about :math:`r=0`,
561561
namely,
562562

563563
.. math:: \frac{1}{1+r} = 1 - r + r^2 - r^3 + \cdots
564564

565-
and the fact that :math:`r` is small to aproximate
565+
and the fact that :math:`r` is small to approximate
566566
:math:`\frac{1}{1+r} \approx 1 - r`.
567567

568568
Use this approximation to write :math:`p_0` as
@@ -619,26 +619,26 @@ We could have also approximated by removing the second term
619619
approximation.
620620

621621
We will plot the true finite stream present-value and the two
622-
approximations, under different values of :math:`T`, and :math:`g` and :math:`r` in python.
622+
approximations, under different values of :math:`T`, and :math:`g` and :math:`r` in Python.
623623

624624
First we plot the true finite stream present-value after computing it
625625
below
626626

627627
.. code-block:: python3
628628
629629
# True present value of a finite lease
630-
def finite_lease_pv(T, g, r, x_0):
630+
def finite_lease_pv_true(T, g, r, x_0):
631631
G = (1 + g)
632632
R = (1 + r)
633633
return (x_0 * (1 - G**(T + 1) * R**(-T - 1))) / (1 - G * R**(-1))
634634
# First approximation for our finite lease
635635
636-
def finite_lease_pv_approx_f(T, g, r, x_0):
636+
def finite_lease_pv_approx_1(T, g, r, x_0):
637637
p = x_0 * (T + 1) + x_0 * r * g * (T + 1) / (r - g)
638638
return p
639639
640640
# Second approximation for our finite lease
641-
def finite_lease_pv_approx_s(T, g, r, x_0):
641+
def finite_lease_pv_approx_2(T, g, r, x_0):
642642
return (x_0 * (T + 1))
643643
644644
# Infinite lease
@@ -648,25 +648,32 @@ below
648648
return x_0 / (1 - G * R**(-1))
649649
650650
651-
Now that we have test run our functions, we can plot some outcomes.
651+
Now that we have defined our functions, we can plot some outcomes.
652652

653653
First we study the quality of our approximations
654654

655655
.. code-block:: python3
656656
657+
def plot_function(axes, x_vals, func, args):
658+
axes.plot(x_vals, func(*args), label=func.__name__)
659+
660+
T_max = 50
661+
662+
T = np.arange(0, T_max+1)
657663
g = 0.02
658664
r = 0.03
659665
x_0 = 1
660-
T_max = 50
661-
T = np.arange(0, T_max+1)
666+
667+
our_args = (T, g, r, x_0)
668+
funcs = [finite_lease_pv_true,
669+
finite_lease_pv_approx_1,
670+
finite_lease_pv_approx_2]
671+
## the three functions we want to compare
672+
662673
fig, ax = plt.subplots()
663674
ax.set_title('Finite Lease Present Value $T$ Periods Ahead')
664-
y_1 = finite_lease_pv(T, g, r, x_0)
665-
y_2 = finite_lease_pv_approx_f(T, g, r, x_0)
666-
y_3 = finite_lease_pv_approx_s(T, g, r, x_0)
667-
ax.plot(T, y_1, label='True T-period Lease PV')
668-
ax.plot(T, y_2, label='T-period Lease First-order Approx.')
669-
ax.plot(T, y_3, label='T-period Lease First-order Approx. adj.')
675+
for f in funcs:
676+
plot_function(ax, T, f, our_args)
670677
ax.legend()
671678
ax.set_xlabel('$T$ Periods Ahead')
672679
ax.set_ylabel('Present Value, $p_0$')
@@ -686,18 +693,18 @@ over different lease lengths :math:`T`.
686693
T = np.arange(0, T_max+1)
687694
fig, ax = plt.subplots()
688695
ax.set_title('Infinite and Finite Lease Present Value $T$ Periods Ahead')
689-
y_1 = finite_lease_pv(T, g, r, x_0)
690-
y_2 = np.ones(T_max+1)*infinite_lease(g, r, x_0)
691-
ax.plot(T, y_1, label='T-period lease PV')
692-
ax.plot(T, y_2, '--', label='Infinite lease PV')
696+
f_1 = finite_lease_pv_true(T, g, r, x_0)
697+
f_2 = np.ones(T_max+1)*infinite_lease(g, r, x_0)
698+
ax.plot(T, f_1, label='T-period lease PV')
699+
ax.plot(T, f_2, '--', label='Infinite lease PV')
693700
ax.set_xlabel('$T$ Periods Ahead')
694701
ax.set_ylabel('Present Value, $p_0$')
695702
ax.legend()
696703
plt.show()
697704
698-
The above graphs shows how as duration :math:`T \rightarrow +\infty`,
705+
The graph above shows how as duration :math:`T \rightarrow +\infty`,
699706
the value of a lease of duration :math:`T` approaches the value of a
700-
perpetural lease.
707+
perpetual lease.
701708

702709
Now we consider two different views of what happens as :math:`r` and
703710
:math:`g` covary
@@ -712,30 +719,18 @@ Now we consider two different views of what happens as :math:`r` and
712719
ax.set_xlabel('$T$ periods ahead')
713720
T_max = 10
714721
T=np.arange(0, T_max+1)
715-
# r >> g, much bigger than g
716-
r = 0.9
717-
g = 0.4
718-
ax.plot(finite_lease_pv(T, g, r, x_0), label='$r\gg g$')
719-
# r > g
720-
r = 0.5
721-
g = 0.4
722-
ax.plot(finite_lease_pv(T, g, r, x_0), label='$r>g$', color='green')
723-
724-
# r ~ g, not defined when r = g, but approximately goes to straight
725-
# line with slope 1
726-
r = 0.4001
727-
g = 0.4
728-
ax.plot(finite_lease_pv(T, g, r, x_0), label=r'$r \approx g$', color='orange')
729-
730-
# r < g
731-
r = 0.4
732-
g = 0.5
733-
ax.plot(finite_lease_pv(T, g, r, x_0), label='$r<g$', color='red')
722+
723+
rs, gs = (0.9, 0.5, 0.4001, 0.4), (0.4, 0.4, 0.4, 0.5),
724+
comparisons = ('$\gg$', '$>$', r'$\approx$', '$<$')
725+
for r, g, comp in zip(rs, gs, comparisons):
726+
ax.plot(finite_lease_pv_true(T, g, r, x_0), label=f'r(={r}) {comp} g(={g})')
727+
734728
ax.legend()
735729
plt.show()
736730
737731
738-
The above graphs gives a big hint for why the condition :math:`r > g` is
732+
733+
This graph gives a big hint for why the condition :math:`r > g` is
739734
necessary if a lease of length :math:`T = +\infty` is to have finite
740735
value.
741736

@@ -755,7 +750,7 @@ visualization!
755750
g = np.arange(0.011, 0.991, 0.005)
756751
757752
rr, gg = np.meshgrid(r, g)
758-
z = finite_lease_pv(T, gg, rr, x_0)
753+
z = finite_lease_pv_true(T, gg, rr, x_0)
759754
760755
# Removes points where undefined
761756
same = (rr == gg)
@@ -809,10 +804,10 @@ After that, we'll use SymPy to compute derivatives
809804
810805
We can see that for :math:`\frac{\partial p_0}{\partial r}<0` as long as
811806
:math:`r>g`, :math:`r>0` and :math:`g>0` and :math:`x_0` is positive,
812-
this equation will always be negative.
807+
so :math:`\frac{\partial p_0}{\partial r}` will always be negative.
813808

814-
Similarly, :math:`\frac{\partial p_0}{\partial g}>0` as long as :math:`r>g`, :math:`r>0` and :math:`g>0` and :math:`x_0` is positive, this equation
815-
will always be postive.
809+
Similarly, :math:`\frac{\partial p_0}{\partial g}>0` as long as :math:`r>g`, :math:`r>0` and :math:`g>0` and :math:`x_0` is positive, so :math:`\frac{\partial p_0}{\partial g}`
810+
will always be positive.
816811

817812

818813

@@ -859,54 +854,50 @@ i.e., the fraction of income that is consumed
859854

860855
.. code-block:: python3
861856
862-
# Changing fraction of consumption
863-
b_0 = 1/3
864-
b_1 = 2/3
865-
b_2 = 5/6
866-
b_3 = 0.9
857+
bs = (1/3, 2/3, 5/6, 0.9)
867858
868859
fig,ax = plt.subplots()
869860
ax.set_title('Changing Consumption as a Fraction of Income')
870861
ax.set_ylabel('$y_t$')
871862
ax.set_xlabel('$t$')
872863
x = np.arange(0, T+1)
873-
for b in (b_0, b_1, b_2, b_3):
864+
for b in bs:
874865
y = calculate_y(i_0, b, g_0, T, y_init)
875866
ax.plot(x, y, label=r'$b=$'+f"{b:.2f}")
876867
ax.legend()
877868
plt.show()
878869
879-
Increasing the marginal propensity to consumer :math:`b` increases the
880-
path of output over time
870+
871+
Increasing the marginal propensity to consume :math:`b` increases the
872+
path of output over time.
873+
874+
Now we will compare the effects on output of increases in investment and government spending.
881875

882876
.. code-block:: python3
883877
884-
x = np.arange(0, T+1)
885-
y_0 = calculate_y(i_0, b, g_0, T, y_init)
886878
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(6, 10))
887879
fig.subplots_adjust(hspace=0.3)
888-
889-
# Changing initial investment:
890-
i_1 = 0.4
891-
y_1 = calculate_y(i_1, b, g_0, T, y_init)
892-
ax1.set_title('An Increase in Investment on Output')
893-
ax1.plot(x, y_0, label=r'$i=0.3$', linestyle='--')
894-
ax1.plot(x, y_1, label=r'$i=0.4$')
895-
ax1.legend()
896-
ax1.set_ylabel('$y_t$')
897-
ax1.set_xlabel('$t$')
898-
899-
# Changing government spending
900-
g_1 = 0.4
901-
y_1 = calculate_y(i_0, b, g_1, T, y_init)
902-
ax2.set_title('An Increase in Government Spending on Output')
903-
ax2.plot(x, y_0, label=r'$g=0.3$', linestyle='--')
904-
ax2.plot(x, y_1, label=r'$g=0.4$')
905-
ax2.legend()
906-
ax2.set_ylabel('$y_t$')
907-
ax2.set_xlabel('$t$')
880+
881+
x = np.arange(0, T+1)
882+
values = [0.3, 0.4]
883+
884+
for i in values:
885+
y = calculate_y(i, b, g_0, T, y_init)
886+
ax1.plot(x, y, label=f"i={i}")
887+
for g in values:
888+
y = calculate_y(i_0, b, g, T, y_init)
889+
ax2.plot(x, y, label=f"g={g}")
890+
891+
axes = ax1, ax2
892+
param_labels = "Investment", "Government Spending"
893+
for ax, param in zip(axes, param_labels):
894+
ax.set_title(f'An Increase in {param} on Output')
895+
ax.legend(loc ="lower right")
896+
ax.set_ylabel('$y_t$')
897+
ax.set_xlabel('$t$')
908898
plt.show()
909899
900+
910901
Notice here, whether government spending increases from 0.3 to 0.4 or
911902
investment increases from 0.3 to 0.4, the shifts in the graphs are
912903
identical.

0 commit comments

Comments
 (0)