Skip to content

Commit d0336d2

Browse files
Tom's edits of oop notebook
1 parent b9e5831 commit d0336d2

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

source/rst/python_oop.rst

+18-18
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ OOP is useful for the same reason that abstraction is useful: for recognizing an
148148

149149
For example,
150150

151-
* *a Markov chain* consists of a set of states, an initial probability distribution over states, and a collection of transition probabilities for moving across states
151+
* *a Markov chain* consists of a set of states, an initial probability distribution over states, and a collection of probabilities of moving across states
152152

153153
* *a general equilibrium theory* consists of a commodity space, preferences, technologies, and an equilibrium definition
154154

@@ -213,7 +213,7 @@ For example
213213
print("w0,w1,w2,w3,w4 = ", w0,w1,w2,w3,w4)
214214
215215
216-
A Class bundles a set of data tied to a particular *instance* together with a collection of functions that operate on the data.
216+
A *Class* bundles a set of data tied to a particular *instance* together with a collection of functions that operate on the data.
217217

218218
In our example, an *instance* will be the name of particular *person* whose *instance data* consist solely of its wealth.
219219

@@ -302,7 +302,7 @@ After we create consumer :math:`c1` and endow it with initial wealth :math:`10`,
302302
c1.spend(100)
303303
304304
305-
We can of course create multiple instances each with its own data
305+
We can of course create multiple instances, i.e., multiple consumers, each with its own name and data
306306

307307
.. code-block:: python3
308308
@@ -316,7 +316,7 @@ We can of course create multiple instances each with its own data
316316
c1.wealth
317317
318318
319-
In fact, each instance stores its data in a separate namespace dictionary
319+
Each instance, i.e., each consumer, stores its data in a separate namespace dictionary
320320

321321
.. code-block:: python3
322322
@@ -340,9 +340,9 @@ The rules for using ``self`` in creating a Class are that
340340

341341
* Any instance data should be prepended with ``self``
342342

343-
* e.g., the ``earn`` method references ``self.wealth`` rather than just ``wealth``
343+
* e.g., the ``earn`` method uses ``self.wealth`` rather than just ``wealth``
344344

345-
* Any method defined within the class should have ``self`` as its first argument
345+
* A method defined within the code that defines the class should have ``self`` as its first argument
346346

347347
* e.g., ``def earn(self, y)`` rather than just ``def earn(y)``
348348

@@ -355,7 +355,7 @@ Details
355355

356356
In this section, we look at some more formal details related to classes and ``self``
357357

358-
* You might wish to skip to :ref:`the next section <oop_solow_growth>` on first pass of this lecture.
358+
* You might wish to skip to :ref:`the next section <oop_solow_growth>` the first time you read this lecture.
359359

360360
* You can return to these details after you've familiarized yourself with more examples.
361361

@@ -412,8 +412,8 @@ Example: The Solow Growth Model
412412

413413
For our next example, let's write a simple class to implement the Solow growth model.
414414

415-
The Solow growth model is a neoclassical growth model where the amount of
416-
capital stock per capita :math:`k_t` evolves according to the rule
415+
The Solow growth model is a neoclassical growth model in which the per capita
416+
capital stock :math:`k_t` evolves according to the rule
417417

418418
.. math::
419419
:label: solow_lom
@@ -423,13 +423,13 @@ capital stock per capita :math:`k_t` evolves according to the rule
423423
424424
Here
425425

426-
* :math:`s` is an exogenously given savings rate
426+
* :math:`s` is an exogenously given saving rate
427427
* :math:`z` is a productivity parameter
428428
* :math:`\alpha` is capital's share of income
429429
* :math:`n` is the population growth rate
430430
* :math:`\delta` is the depreciation rate
431431

432-
The **steady state** of the model is the :math:`k` that solves :eq:`solow_lom` when :math:`k_{t+1} = k_t = k`.
432+
A **steady state** of the model is a :math:`k` that solves :eq:`solow_lom` when :math:`k_{t+1} = k_t = k`.
433433

434434
Here's a class that implements this model.
435435

@@ -512,7 +512,7 @@ The common steady state is also plotted for comparison
512512
lb = f'capital series from initial state {s.k}'
513513
ax.plot(s.generate_sequence(T), 'o-', lw=2, alpha=0.6, label=lb)
514514
515-
ax.set_xlabel('$k_{t+1}$', fontsize=14)
515+
ax.set_xlabel('$t$', fontsize=14)
516516
ax.set_ylabel('$k_t$', fontsize=14)
517517
ax.legend()
518518
plt.show()
@@ -522,7 +522,7 @@ The common steady state is also plotted for comparison
522522
Example: A Market
523523
-----------------
524524

525-
Next, let's write a class for a simple one good market where agents are price takers.
525+
Next, let's write a class for competitive market in which buyers and sellers are both price takers.
526526

527527
The market consists of the following objects:
528528

@@ -532,7 +532,7 @@ The market consists of the following objects:
532532

533533
Here
534534

535-
* :math:`p` is price paid by the consumer, :math:`Q` is quantity and :math:`t` is a per-unit tax.
535+
* :math:`p` is price paid by the buyer, :math:`Q` is quantity and :math:`t` is a per-unit tax.
536536

537537
* Other symbols are demand and supply parameters.
538538

@@ -559,7 +559,7 @@ Here's our implementation.
559559
raise ValueError('Insufficient demand.')
560560
561561
def price(self):
562-
"Return equilibrium price"
562+
"Compute equilibrium price"
563563
return (self.ad - self.az + self.bz * self.tax) / (self.bd + self.bz)
564564
565565
def quantity(self):
@@ -667,7 +667,7 @@ Example: Chaos
667667

668668
Let's look at one more example, related to chaotic dynamics in nonlinear systems.
669669

670-
One simple transition rule that can generate complex dynamics is the logistic map
670+
A simple transition rule that can generate erratic time paths is the logistic map
671671

672672
.. math::
673673
:label: quadmap2
@@ -685,7 +685,7 @@ Here's one implementation
685685
686686
class Chaos:
687687
"""
688-
Models the dynamical system with :math:`x_{t+1} = r x_t (1 - x_t)`
688+
Models the dynamical system :math:`x_{t+1} = r x_t (1 - x_t)`
689689
"""
690690
def __init__(self, x0, r):
691691
"""
@@ -775,7 +775,7 @@ Special Methods
775775
.. index::
776776
single: Object-Oriented Programming; Special Methods
777777

778-
Python provides special methods with which some neat tricks can be performed.
778+
Python provides special methods that come in handy.
779779

780780
For example, recall that lists and tuples have a notion of length and that this length can be queried via the ``len`` function
781781

0 commit comments

Comments
 (0)