This notebook provides the basics of the microeconomic, agent-type class which is fundamental for HARK.
HARK AgentType classes were designed to solve the consumer problem.
In the most basic formulation, the consumer problem is given as follows. The consumer lives T+1 periods (T $\leq \infty$) and during her lifetime receives the same income $Y$. In each period t (0$\leq$ t$\leq$ T) she can spend it on the consumption $C_t$ or invest in an asset $A_t$ with risk free interest rate R. She maximize the lifetime utility, by solving the following Bellman equation defined on the "cash in hand" state space $M_t = C_t +A_t$:
For $t<T+1$ \begin{eqnarray*} V_t(M_t) &=& \max_{C_t} U(C_t) + \beta V_{t+1}(M_{t+1}), \\ & s.t. & \\ A_t &=& M_t - C_t, \\ M_{t+1} &=& R (M_{t}-C_{t}) + Y, \\ \end{eqnarray*} for $t \geq T+1$ \begin{eqnarray*} V_t(M_t) &=& 0 \end{eqnarray*}
Where $\beta <1 $ is a discount factor and $U(C)$ is a standard CRRA utility function: $$ U(C)=\frac{C^{1-\rho}}{1-\rho} $$
Obviously, HARK was designed to solve much more complicated consumer problems. However, it was written in the object programming paradigma (OPP). Thus, the class designed to solve such basic problem: $\texttt{PerfForesightConsumerType}$ is then a foundation (parent/subclass in the OPP language) for the more advanced classes with the heterogeneous agents. In the diagram you can observe the inheritance between some of the HARK Agent-type classes:
As you can observe, the $\texttt{AgentType}$ superclass is the most general type of framework for the microeconomic models implemented in HARK. The child/subclass of $\texttt{AgentType}$ is $\texttt{PerfForesightConsumerType}$. There, you will need to define parameters, or attributes in OPP (such as $T$, $\beta$, and so on). Next, there are classes which inherit those attributes, and further incorporate the heterogeneity of agents.
In these classes, you will need to additionally define parameters of the heterogeneity you wish to model (idiosyncratic shocks to income and aggregate productivity shocks are two common examples). Moreover, methods (which define how the object is created, how the solution is presented, etc.) of the subclasses are the same or modified methods of the parent class.
Therefore, to master the basics of HARK microclass you will first need to learn the $\texttt{PerfForesightConsumerType}$ class. Consequently, this tutorial aims to teach you this. However, the majority of the presented methods are general for the HARK agent-type objects (though it may involve assigning more parameters).
In the next notebooks, the class $\texttt{IndShockConsumerType}$ with idiosyncratic income shocks is a more specific example of using the HARK microclass.
In this part, you learn basics of the perfect foresight model. We will solve the example of the consumer problem presented in the introduction.
First, you need to import HARK and a few additional libraries. Importantly, to use $\texttt{PerfForesightConsumerType}$ you also need to import HARK.ConsumptionSaving.ConsIndShockModel sublibrary.
# import sys
# import os
# sys.path.insert(0, os.path.abspath('../../../.'))
import matplotlib.pyplot as plt
import numpy as np
from copy import deepcopy
from HARK.ConsumptionSaving.ConsIndShockModel import *
from HARK.utilities import plot_funcs
The most basic way of creating HARK object is to call its constructor (in OPP method which create the object, called by the class name).
For $\texttt{PerfForesightConsumerType}$ we need to set:
Additionally, you need to define two parameters which do not occur in the presented example, but nevertheless can be useful:
We call our first HARK object Example_agent_1 and set the example values of the parameters.
Example_agent_1 = PerfForesightConsumerType(
cycles=0, CRRA=2.0, Rfree=1.03, DiscFac=0.99, LivPrb=1.0, PermGroFac=1.0
)
Because we did not assume growth in 𝑌 or survival uncertainty , we set these values to 1.
The second method involves creating a dictionary: a list of parameters' names and values. Here we define the dictionary with the same values as in the first example.
First_dictionary = {
"CRRA": 2.0,
"DiscFac": 0.99,
"Rfree": 1.03,
"cycles": 0,
"LivPrb": [1.00],
"PermGroFac": [1.00],
}
To create an object with a dictionary, use the constructor with the previously defined dictionary as an argument:
Example_agent_2 = PerfForesightConsumerType(**First_dictionary)
Although the first method is easier, we recommend defining a dictionary whenever you create a HARK object. First, it makes your code cleaner. Second, it enables you to create multiple objects with the same dictionary (the importantance of which will become apparent as we move on to creating macro classes).
The presented here methods work also for the more sophisticated HARK object (however you will need to specify more parameters).
Once creating an agent-type object, you can use its set of parameters to create another. To do so you need to use deepcopy method from copy package.
Example_agent_3 = deepcopy(Example_agent_2)
Note: Do not only use an assignment operator (=) because it does not create new object. For example, a command such as:
Example_agent_4 = Example_agent_2
does not create a new object. It will only gives a new name to the object Example_agent_2 (this gives a single agent object both names Example_agent_2 and Example_agent_4).
You can easily change the parameter value of the object by "." operator.
For example, to change the discount factor value of the object created in the previous subsection:
Example_agent_3.DiscFac = 0.95
To solve agent type problems such as the on presented in the example, you need to find a value function from the Bellman equations and the policy functions. In our case, the only policy function is a consumption function: a function that for each age t and cash-in-hand $M_t$, specify the optimal consumption level: $c_t(M_t)$.
To solve a model in HARK, you need to use $\texttt{solve}$ method. For example, if we want to solve the model with parameters of the object Example_agent_2:
Example_agent_2.solve()
Solve
method finds the value function and consumption function for each period t of the consumer's life (in case of the infinite T, it specifies only one set of functions; because all the parameters are stable and lifespan is always infinite, the functions are the same for each $t$).
Besides consumption and value functions, solve
method create also a few attributes, the most important is minimal cash-in-hand value for which the problem has a solution.
The exact name of these attributes in HARK are:
To get access to the value/consumption function you need to specify the period t and the object name, using two times operator. So to get access to the value function, consumption function and mNrmMin for the solved example:
Example_agent_2.solution[0].vFunc
Example_agent_2.solution[0].cFunc
Example_agent_2.solution[0].mNrmMin
-33.33330059492335
As you can see, only mNrmMin can be printed as a value. However, the value and consumption functions can be plotted.
After $\texttt{solve}$ method is used, the value and consumption functions can be plotted. HARK dedicated function for doing so is plot_funcs
. As arguments, you need to give a function from the solution (possible a few functions) and the limits of interval for which you want to make a plot.
For example, we can plot consumption and value functions on the interval from mNrmMin to -mNrmMin.
min_v = Example_agent_2.solution[0].mNrmMin
max_v = -Example_agent_2.solution[0].mNrmMin
print("Consumption function")
plot_funcs([Example_agent_2.solution[0].cFunc], min_v, max_v)
print("Value function")
plot_funcs([Example_agent_2.solution[0].vFunc], min_v, max_v)
Consumption function
Value function
/Users/dc/anaconda3/envs/journey_1/lib/python3.10/site-packages/HARK/utilities.py:139: RuntimeWarning: divide by zero encountered in reciprocal return c ** (1.0 - gam) / (1.0 - gam)
Next step is to simulate the agent behavior. To do so, you first need to set a few parameters for the sake of the simulation:
Moreover, HARK enables simulation of the model with the log-normal distributions of the initial assets and incomes. You need to set the parameters:
Lastly, using HARK agent type class, you can also set the aggregate income increase (so that the rate of the income increase is common to all agents). You may then set a parameter:
In our example, we simulate 1 agent, as it is a representative agent model. Time flow is chronological and there is no initial heterogeneity. Thus, std of the initial assets and income distributions are set to 0. The initial assets and income are set to 1.0. There is no aggregate income increase, so we set the income growth factor to 1. We simulate 1000 periods and assume an infinitely lived agent.
To declare the values of these parameters, we create a new dictionary:
Simulation_dictionary = {
"AgentCount": 1,
"aNrmInitMean": 0.0,
"aNrmInitStd": 0.0,
"pLvlInitMean": 0.0,
"pLvlInitStd": 0.0,
"PermGroFacAgg": 1.0,
"T_cycle": 1,
"T_sim": 1000,
"T_age": None,
}
Next, you need to update the object. To do so we use setattr function, which adds the parameters' values to the defined agent object.
for key, value in Simulation_dictionary.items():
setattr(Example_agent_2, key, value)
Finally, you can start our simulation. First, you need to decide which variables you want to track, we choose an assets level and consumption level, in the code they are called: $\texttt{aNrmNow}$ and $\texttt{cNrmNow}$. Next, you need to initialize the simulation by $\texttt{initialize_sim}$ method. Lastly, run the simulation with the $\texttt{simulate}$ method.
Example_agent_2.track_vars = [
"aNrm",
"cNrm",
] # should these be 'aLvl, cLvl' since the normalized versions of these variables isn't introduced until the next section?
Example_agent_2.initialize_sim()
Example_agent_2.simulate()
{'aNrm': array([[1.33647048e+00], [1.67623840e+00], [2.01933608e+00], [2.36579615e+00], [2.71565156e+00], [3.06893558e+00], [3.42568182e+00], [3.78592421e+00], [4.14969700e+00], [4.51703480e+00], [4.88797255e+00], [5.26254552e+00], [5.64078934e+00], [6.02273998e+00], [6.40843378e+00], [6.79790741e+00], [7.19119792e+00], [7.58834271e+00], [7.98937956e+00], [8.39434660e+00], [8.80328236e+00], [9.21622573e+00], [9.63321598e+00], [1.00542928e+01], [1.04794962e+01], [1.09088666e+01], [1.13424449e+01], [1.17802723e+01], [1.22223904e+01], [1.26688413e+01], [1.31196675e+01], [1.35749119e+01], [1.40346177e+01], [1.44988286e+01], [1.49675889e+01], [1.54409430e+01], [1.59189360e+01], [1.64016135e+01], [1.68890212e+01], [1.73812056e+01], [1.78782134e+01], [1.83800919e+01], [1.88868889e+01], [1.93986525e+01], [1.99154315e+01], [2.04372749e+01], [2.09642325e+01], [2.14963543e+01], [2.20336910e+01], [2.25762936e+01], [2.31242137e+01], [2.36775035e+01], [2.42362156e+01], [2.48004032e+01], [2.53701198e+01], [2.59454197e+01], [2.65263576e+01], [2.71129887e+01], [2.77053689e+01], [2.83035545e+01], [2.89076023e+01], [2.95175699e+01], [3.01335152e+01], [3.07554968e+01], [3.13835739e+01], [3.20178062e+01], [3.26582541e+01], [3.33049784e+01], [3.39580406e+01], [3.46175029e+01], [3.52834280e+01], [3.59558793e+01], [3.66349206e+01], [3.73206166e+01], [3.80130325e+01], [3.87122341e+01], [3.94182880e+01], [4.01312612e+01], [4.08512217e+01], [4.15782378e+01], [4.23123788e+01], [4.30537144e+01], [4.38023151e+01], [4.45582522e+01], [4.53215976e+01], [4.60924239e+01], [4.68708043e+01], [4.76568129e+01], [4.84505244e+01], [4.92520144e+01], [5.00613591e+01], [5.08786354e+01], [5.17039211e+01], [5.25372947e+01], [5.33788355e+01], [5.42286234e+01], [5.50867393e+01], [5.59532648e+01], [5.68282823e+01], [5.77118751e+01], [5.86041272e+01], [5.95051235e+01], [6.04149496e+01], [6.13336920e+01], [6.22614383e+01], [6.31982765e+01], [6.41442959e+01], [6.50995863e+01], [6.60642386e+01], [6.70383446e+01], [6.80219970e+01], [6.90152892e+01], [7.00183158e+01], [7.10311722e+01], [7.20539546e+01], [7.30867604e+01], [7.41296878e+01], [7.51828360e+01], [7.62463051e+01], [7.73201963e+01], [7.84046118e+01], [7.94996546e+01], [8.06054290e+01], [8.17220400e+01], [8.28495939e+01], [8.39881980e+01], [8.51379605e+01], [8.62989907e+01], [8.74713992e+01], [8.86552974e+01], [8.98507979e+01], [9.10580144e+01], [9.22770617e+01], [9.35080558e+01], [9.47511138e+01], [9.60063539e+01], [9.72738954e+01], [9.85538589e+01], [9.98463662e+01], [1.01151540e+02], [1.02469505e+02], [1.03800386e+02], [1.05144310e+02], [1.06501404e+02], [1.07871798e+02], [1.09255622e+02], [1.10653008e+02], [1.12064088e+02], [1.13488997e+02], [1.14927870e+02], [1.16380844e+02], [1.17848057e+02], [1.19329649e+02], [1.20825761e+02], [1.22336535e+02], [1.23862115e+02], [1.25402646e+02], [1.26958274e+02], [1.28529147e+02], [1.30115415e+02], [1.31717228e+02], [1.33334739e+02], [1.34968103e+02], [1.36617473e+02], [1.38283007e+02], [1.39964864e+02], [1.41663203e+02], [1.43378186e+02], [1.45109975e+02], [1.46858737e+02], [1.48624637e+02], [1.50407842e+02], [1.52208523e+02], [1.54026851e+02], [1.55862999e+02], [1.57717141e+02], [1.59589454e+02], [1.61480116e+02], [1.63389306e+02], [1.65317207e+02], [1.67264001e+02], [1.69229874e+02], [1.71215013e+02], [1.73219606e+02], [1.75243845e+02], [1.77287921e+02], [1.79352030e+02], [1.81436367e+02], [1.83541130e+02], [1.85666520e+02], [1.87812740e+02], [1.89979992e+02], [1.92168484e+02], [1.94378424e+02], [1.96610021e+02], [1.98863487e+02], [2.01139038e+02], [2.03436890e+02], [2.05757260e+02], [2.08100371e+02], [2.10466444e+02], [2.12855705e+02], [2.15268381e+02], [2.17704702e+02], [2.20164898e+02], [2.22649205e+02], [2.25157858e+02], [2.27691096e+02], [2.30249160e+02], [2.32832294e+02], [2.35440742e+02], [2.38074754e+02], [2.40734579e+02], [2.43420470e+02], [2.46132684e+02], [2.48871477e+02], [2.51637111e+02], [2.54429848e+02], [2.57249955e+02], [2.60097698e+02], [2.62973350e+02], [2.65877184e+02], [2.68809475e+02], [2.71770503e+02], [2.74760549e+02], [2.77779899e+02], [2.80828838e+02], [2.83907657e+02], [2.87016648e+02], [2.90156108e+02], [2.93326335e+02], [2.96527631e+02], [2.99760299e+02], [3.03024648e+02], [3.06320988e+02], [3.09649633e+02], [3.13010898e+02], [3.16405104e+02], [3.19832574e+02], [3.23293633e+02], [3.26788611e+02], [3.30317840e+02], [3.33881656e+02], [3.37480397e+02], [3.41114406e+02], [3.44784030e+02], [3.48489615e+02], [3.52231516e+02], [3.56010088e+02], [3.59825690e+02], [3.63678685e+02], [3.67569440e+02], [3.71498325e+02], [3.75465714e+02], [3.79471983e+02], [3.83517514e+02], [3.87602691e+02], [3.91727904e+02], [3.95893544e+02], [4.00100007e+02], [4.04347695e+02], [4.08637010e+02], [4.12968361e+02], [4.17342159e+02], [4.21758821e+02], [4.26218767e+02], [4.30722421e+02], [4.35270211e+02], [4.39862569e+02], [4.44499933e+02], [4.49182744e+02], [4.53911447e+02], [4.58686492e+02], [4.63508332e+02], [4.68377427e+02], [4.73294239e+02], [4.78259237e+02], [4.83272892e+02], [4.88335681e+02], [4.93448086e+02], [4.98610594e+02], [5.03823694e+02], [5.09087883e+02], [5.14403662e+02], [5.19771535e+02], [5.25192015e+02], [5.30665616e+02], [5.36192858e+02], [5.41774268e+02], [5.47410376e+02], [5.53101719e+02], [5.58848837e+02], [5.64652278e+02], [5.70512593e+02], [5.76430339e+02], [5.82406080e+02], [5.88440384e+02], [5.94533824e+02], [6.00686981e+02], [6.06900439e+02], [6.13174790e+02], [6.19510630e+02], [6.25908562e+02], [6.32369194e+02], [6.38893141e+02], [6.45481023e+02], [6.52133467e+02], [6.58851106e+02], [6.65634578e+02], [6.72484529e+02], [6.79401609e+02], [6.86386478e+02], [6.93439800e+02], [7.00562244e+02], [7.07754489e+02], [7.15017219e+02], [7.22351124e+02], [7.29756902e+02], [7.37235258e+02], [7.44786902e+02], [7.52412553e+02], [7.60112935e+02], [7.67888783e+02], [7.75740834e+02], [7.83669836e+02], [7.91676544e+02], [7.99761717e+02], [8.07926126e+02], [8.16170547e+02], [8.24495764e+02], [8.32902569e+02], [8.41391762e+02], [8.49964149e+02], [8.58620547e+02], [8.67361778e+02], [8.76188674e+02], [8.85102074e+02], [8.94102827e+02], [9.03191787e+02], [9.12369821e+02], [9.21637800e+02], [9.30996606e+02], [9.40447129e+02], [9.49990268e+02], [9.59626931e+02], [9.69358034e+02], [9.79184502e+02], [9.89107271e+02], [9.99127284e+02], [1.00924549e+03], [1.01946286e+03], [1.02978036e+03], [1.04019898e+03], [1.05071969e+03], [1.06134351e+03], [1.07207145e+03], [1.08290452e+03], [1.09384375e+03], [1.10489019e+03], [1.11604489e+03], [1.12730890e+03], [1.13868331e+03], [1.15016918e+03], [1.16176761e+03], [1.17347971e+03], [1.18530659e+03], [1.19724938e+03], [1.20930920e+03], [1.22148721e+03], [1.23378457e+03], [1.24620244e+03], [1.25874201e+03], [1.27140447e+03], [1.28419102e+03], [1.29710289e+03], [1.31014128e+03], [1.32330746e+03], [1.33660267e+03], [1.35002817e+03], [1.36358524e+03], [1.37727517e+03], [1.39109926e+03], [1.40505883e+03], [1.41915521e+03], [1.43338973e+03], [1.44776376e+03], [1.46227864e+03], [1.47693578e+03], [1.49173656e+03], [1.50668238e+03], [1.52177468e+03], [1.53701488e+03], [1.55240444e+03], [1.56794482e+03], [1.58363749e+03], [1.59948396e+03], [1.61548572e+03], [1.63164430e+03], [1.64796123e+03], [1.66443808e+03], [1.68107639e+03], [1.69787777e+03], [1.71484380e+03], [1.73197610e+03], [1.74927629e+03], [1.76674603e+03], [1.78438698e+03], [1.80220080e+03], [1.82018921e+03], [1.83835390e+03], [1.85669661e+03], [1.87521908e+03], [1.89392307e+03], [1.91281036e+03], [1.93188275e+03], [1.95114205e+03], [1.97059009e+03], [1.99022873e+03], [2.01005982e+03], [2.03008526e+03], [2.05030696e+03], [2.07072683e+03], [2.09134681e+03], [2.11216887e+03], [2.13319499e+03], [2.15442717e+03], [2.17586743e+03], [2.19751780e+03], [2.21938035e+03], [2.24145715e+03], [2.26375031e+03], [2.28626194e+03], [2.30899419e+03], [2.33194922e+03], [2.35512920e+03], [2.37853636e+03], [2.40217290e+03], [2.42604109e+03], [2.45014319e+03], [2.47448149e+03], [2.49905831e+03], [2.52387598e+03], [2.54893687e+03], [2.57424335e+03], [2.59979785e+03], [2.62560278e+03], [2.65166060e+03], [2.67797378e+03], [2.70454485e+03], [2.73137631e+03], [2.75847072e+03], [2.78583065e+03], [2.81345872e+03], [2.84135755e+03], [2.86952978e+03], [2.89797811e+03], [2.92670524e+03], [2.95571389e+03], [2.98500683e+03], [3.01458684e+03], [3.04445674e+03], [3.07461937e+03], [3.10507759e+03], [3.13583431e+03], [3.16689245e+03], [3.19825495e+03], [3.22992482e+03], [3.26190505e+03], [3.29419869e+03], [3.32680881e+03], [3.35973852e+03], [3.39299094e+03], [3.42656923e+03], [3.46047660e+03], [3.49471626e+03], [3.52929147e+03], [3.56420552e+03], [3.59946174e+03], [3.63506346e+03], [3.67101409e+03], [3.70731704e+03], [3.74397576e+03], [3.78099374e+03], [3.81837450e+03], [3.85612159e+03], [3.89423861e+03], [3.93272918e+03], [3.97159696e+03], [4.01084564e+03], [4.05047897e+03], [4.09050071e+03], [4.13091466e+03], [4.17172468e+03], [4.21293464e+03], [4.25454846e+03], [4.29657010e+03], [4.33900355e+03], [4.38185286e+03], [4.42512209e+03], [4.46881536e+03], [4.51293684e+03], [4.55749071e+03], [4.60248121e+03], [4.64791262e+03], [4.69378926e+03], [4.74011550e+03], [4.78689574e+03], [4.83413443e+03], [4.88183606e+03], [4.93000518e+03], [4.97864636e+03], [5.02776422e+03], [5.07736344e+03], [5.12744875e+03], [5.17802489e+03], [5.22909668e+03], [5.28066898e+03], [5.33274670e+03], [5.38533478e+03], [5.43843822e+03], [5.49206209e+03], [5.54621148e+03], [5.60089153e+03], [5.65610746e+03], [5.71186450e+03], [5.76816797e+03], [5.82502322e+03], [5.88243566e+03], [5.94041074e+03], [5.99895399e+03], [6.05807096e+03], [6.11776729e+03], [6.17804864e+03], [6.23892076e+03], [6.30038943e+03], [6.36246050e+03], [6.42513987e+03], [6.48843350e+03], [6.55234742e+03], [6.61688770e+03], [6.68206048e+03], [6.74787196e+03], [6.81432840e+03], [6.88143612e+03], [6.94920150e+03], [7.01763099e+03], [7.08673109e+03], [7.15650838e+03], [7.22696949e+03], [7.29812113e+03], [7.36997006e+03], [7.44252312e+03], [7.51578720e+03], [7.58976928e+03], [7.66447639e+03], [7.73991564e+03], [7.81609420e+03], [7.89301932e+03], [7.97069830e+03], [8.04913855e+03], [8.12834753e+03], [8.20833275e+03], [8.28910184e+03], [8.37066248e+03], [8.45302241e+03], [8.53618948e+03], [8.62017160e+03], [8.70497675e+03], [8.79061299e+03], [8.87708848e+03], [8.96441144e+03], [9.05259017e+03], [9.14163306e+03], [9.23154858e+03], [9.32234528e+03], [9.41403179e+03], [9.50661685e+03], [9.60010924e+03], [9.69451787e+03], [9.78985171e+03], [9.88611983e+03], [9.98333139e+03], [1.00814956e+04], [1.01806219e+04], [1.02807196e+04], [1.03817983e+04], [1.04838675e+04], [1.05869371e+04], [1.06910167e+04], [1.07961163e+04], [1.09022459e+04], [1.10094156e+04], [1.11176356e+04], [1.12269161e+04], [1.13372676e+04], [1.14487005e+04], [1.15612255e+04], [1.16748533e+04], [1.17895946e+04], [1.19054604e+04], [1.20224616e+04], [1.21406095e+04], [1.22599153e+04], [1.23803903e+04], [1.25020459e+04], [1.26248938e+04], [1.27489456e+04], [1.28742131e+04], [1.30007082e+04], [1.31284431e+04], [1.32574297e+04], [1.33876804e+04], [1.35192076e+04], [1.36520237e+04], [1.37861415e+04], [1.39215736e+04], [1.40583330e+04], [1.41964326e+04], [1.43358856e+04], [1.44767053e+04], [1.46189050e+04], [1.47624983e+04], [1.49074988e+04], [1.50539204e+04], [1.52017769e+04], [1.53510824e+04], [1.55018510e+04], [1.56540973e+04], [1.58078356e+04], [1.59630805e+04], [1.61198468e+04], [1.62781495e+04], [1.64380035e+04], [1.65994241e+04], [1.67624267e+04], [1.69270267e+04], [1.70932398e+04], [1.72610818e+04], [1.74305687e+04], [1.76017165e+04], [1.77745416e+04], [1.79490604e+04], [1.81252896e+04], [1.83032457e+04], [1.84829459e+04], [1.86644072e+04], [1.88476467e+04], [1.90326821e+04], [1.92195308e+04], [1.94082107e+04], [1.95987396e+04], [1.97911357e+04], [1.99854173e+04], [2.01816029e+04], [2.03797112e+04], [2.05797609e+04], [2.07817711e+04], [2.09857611e+04], [2.11917502e+04], [2.13997579e+04], [2.16098042e+04], [2.18219090e+04], [2.20360924e+04], [2.22523748e+04], [2.24707768e+04], [2.26913191e+04], [2.29140228e+04], [2.31389090e+04], [2.33659991e+04], [2.35953148e+04], [2.38268777e+04], [2.40607100e+04], [2.42968338e+04], [2.45352717e+04], [2.47760463e+04], [2.50191805e+04], [2.52646975e+04], [2.55126205e+04], [2.57629732e+04], [2.60157794e+04], [2.62710631e+04], [2.65288486e+04], [2.67891605e+04], [2.70520234e+04], [2.73174624e+04], [2.75855027e+04], [2.78561699e+04], [2.81294896e+04], [2.84054878e+04], [2.86841909e+04], [2.89656253e+04], [2.92498178e+04], [2.95367954e+04], [2.98265853e+04], [3.01192153e+04], [3.04147131e+04], [3.07131067e+04], [3.10144247e+04], [3.13186956e+04], [3.16259484e+04], [3.19362123e+04], [3.22495168e+04], [3.25658917e+04], [3.28853671e+04], [3.32079734e+04], [3.35337413e+04], [3.38627017e+04], [3.41948860e+04], [3.45303257e+04], [3.48690527e+04], [3.52110993e+04], [3.55564980e+04], [3.59052817e+04], [3.62574834e+04], [3.66131368e+04], [3.69722756e+04], [3.73349340e+04], [3.77011464e+04], [3.80709478e+04], [3.84443733e+04], [3.88214584e+04], [3.92022389e+04], [3.95867512e+04], [3.99750316e+04], [4.03671173e+04], [4.07630455e+04], [4.11628537e+04], [4.15665802e+04], [4.19742632e+04], [4.23859415e+04], [4.28016543e+04], [4.32214412e+04], [4.36453419e+04], [4.40733970e+04], [4.45056470e+04], [4.49421332e+04], [4.53828969e+04], [4.58279801e+04], [4.62774252e+04], [4.67312749e+04], [4.71895724e+04], [4.76523613e+04], [4.81196855e+04], [4.85915895e+04], [4.90681183e+04], [4.95493170e+04], [5.00352316e+04], [5.05259081e+04], [5.10213934e+04], [5.15217344e+04], [5.20269788e+04], [5.25371747e+04], [5.30523705e+04], [5.35726153e+04], [5.40979586e+04], [5.46284502e+04], [5.51641408e+04], [5.57050811e+04], [5.62513227e+04], [5.68029176e+04], [5.73599181e+04], [5.79223772e+04], [5.84903486e+04], [5.90638860e+04], [5.96430442e+04], [6.02278783e+04], [6.08184437e+04], [6.14147967e+04], [6.20169941e+04], [6.26250930e+04], [6.32391514e+04], [6.38592276e+04], [6.44853806e+04], [6.51176699e+04], [6.57561558e+04], [6.64008989e+04], [6.70519605e+04], [6.77094026e+04], [6.83732876e+04], [6.90436788e+04], [6.97206399e+04], [7.04042353e+04], [7.10945300e+04], [7.17915896e+04], [7.24954805e+04], [7.32062696e+04], [7.39240245e+04], [7.46488134e+04], [7.53807053e+04], [7.61197699e+04], [7.68660773e+04], [7.76196987e+04], [7.83807055e+04], [7.91491704e+04], [7.99251662e+04], [8.07087669e+04], [8.15000469e+04], [8.22990816e+04], [8.31059469e+04], [8.39207195e+04], [8.47434770e+04], [8.55742975e+04], [8.64132602e+04], [8.72604448e+04], [8.81159319e+04], [8.89798029e+04], [8.98521398e+04], [9.07330258e+04], [9.16225445e+04], [9.25207805e+04], [9.34278194e+04], [9.43437473e+04], [9.52686514e+04], [9.62026197e+04], [9.71457409e+04], [9.80981048e+04], [9.90598020e+04], [1.00030924e+05], [1.01011563e+05], [1.02001812e+05], [1.03001766e+05], [1.04011519e+05], [1.05031169e+05], [1.06060810e+05], [1.07100543e+05], [1.08150465e+05], [1.09210676e+05], [1.10281277e+05], [1.11362371e+05], [1.12454059e+05], [1.13556446e+05], [1.14669636e+05], [1.15793736e+05], [1.16928852e+05], [1.18075092e+05], [1.19232565e+05], [1.20401382e+05], [1.21581654e+05], [1.22773492e+05], [1.23977010e+05], [1.25192323e+05], [1.26419546e+05], [1.27658796e+05], [1.28910190e+05], [1.30173849e+05], [1.31449891e+05], [1.32738439e+05], [1.34039615e+05], [1.35353542e+05], [1.36680346e+05], [1.38020152e+05], [1.39373089e+05], [1.40739285e+05], [1.42118870e+05], [1.43511975e+05], [1.44918732e+05], [1.46339275e+05], [1.47773741e+05], [1.49222263e+05], [1.50684982e+05], [1.52162036e+05], [1.53653564e+05], [1.55159710e+05], [1.56680616e+05], [1.58216427e+05], [1.59767290e+05], [1.61333350e+05], [1.62914759e+05], [1.64511665e+05], [1.66124221e+05], [1.67752581e+05], [1.69396898e+05], [1.71057330e+05], [1.72734035e+05], [1.74427171e+05], [1.76136900e+05], [1.77863384e+05], [1.79606789e+05], [1.81367278e+05], [1.83145021e+05], [1.84940186e+05], [1.86752943e+05], [1.88583466e+05], [1.90431928e+05], [1.92298505e+05], [1.94183375e+05], [1.96086717e+05], [1.98008712e+05], [1.99949542e+05], [2.01909392e+05], [2.03888450e+05], [2.05886902e+05], [2.07904940e+05], [2.09942754e+05], [2.12000539e+05], [2.14078490e+05], [2.16176806e+05], [2.18295685e+05], [2.20435330e+05], [2.22595943e+05], [2.24777731e+05], [2.26980900e+05], [2.29205660e+05], [2.31452224e+05], [2.33720803e+05], [2.36011616e+05], [2.38324878e+05], [2.40660810e+05], [2.43019635e+05], [2.45401577e+05], [2.47806862e+05], [2.50235718e+05], [2.52688378e+05], [2.55165074e+05], [2.57666042e+05], [2.60191520e+05], [2.62741748e+05], [2.65316968e+05], [2.67917425e+05], [2.70543367e+05], [2.73195044e+05], [2.75872707e+05], [2.78576612e+05], [2.81307015e+05], [2.84064177e+05], [2.86848358e+05], [2.89659825e+05], [2.92498845e+05], [2.95365688e+05], [2.98260625e+05], [3.01183934e+05], [3.04135891e+05], [3.07116777e+05], [3.10126877e+05], [3.13166475e+05], [3.16235862e+05], [3.19335330e+05], [3.22465172e+05], [3.25625687e+05], [3.28817176e+05], [3.32039941e+05], [3.35294290e+05], [3.38580531e+05], [3.41898979e+05], [3.45249947e+05], [3.48633755e+05], [3.52050725e+05], [3.55501181e+05], [3.58985452e+05], [3.62503869e+05], [3.66056767e+05], [3.69644484e+05], [3.73267361e+05], [3.76925742e+05], [3.80619976e+05], [3.84350413e+05], [3.88117410e+05], [3.91921323e+05], [3.95762515e+05], [3.99641351e+05], [4.03558199e+05], [4.07513434e+05], [4.11507430e+05], [4.15540567e+05], [4.19613230e+05], [4.23725805e+05], [4.27878683e+05], [4.32072261e+05], [4.36306935e+05], [4.40583110e+05], [4.44901192e+05], [4.49261592e+05], [4.53664723e+05], [4.58111006e+05], [4.62600863e+05], [4.67134721e+05], [4.71713011e+05], [4.76336169e+05], [4.81004634e+05], [4.85718851e+05], [4.90479267e+05], [4.95286336e+05], [5.00140514e+05], [5.05042264e+05], [5.09992052e+05], [5.14990347e+05], [5.20037627e+05], [5.25134370e+05], [5.30281063e+05], [5.35478193e+05], [5.40726255e+05], [5.46025749e+05], [5.51377178e+05], [5.56781052e+05], [5.62237885e+05], [5.67748195e+05], [5.73312506e+05], [5.78931348e+05], [5.84605256e+05], [5.90334768e+05]]), 'cNrm': array([[6.93529520e-01], [7.00326193e-01], [7.07189473e-01], [7.14120015e-01], [7.21118476e-01], [7.28185523e-01], [7.35321828e-01], [7.42528069e-01], [7.49804932e-01], [7.57153108e-01], [7.64573298e-01], [7.72066206e-01], [7.79632546e-01], [7.87273036e-01], [7.94988404e-01], [8.02779383e-01], [8.10646714e-01], [8.18591146e-01], [8.26613434e-01], [8.34714341e-01], [8.42894638e-01], [8.51155103e-01], [8.59496521e-01], [8.67919685e-01], [8.76425398e-01], [8.85014467e-01], [8.93687710e-01], [9.02445951e-01], [9.11290024e-01], [9.20220770e-01], [9.29239037e-01], [9.38345685e-01], [9.47541579e-01], [9.56827593e-01], [9.66204611e-01], [9.75673525e-01], [9.85235235e-01], [9.94890650e-01], [1.00464069e+00], [1.01448628e+00], [1.02442836e+00], [1.03446787e+00], [1.04460577e+00], [1.05484302e+00], [1.06518060e+00], [1.07561949e+00], [1.08616068e+00], [1.09680517e+00], [1.10755398e+00], [1.11840813e+00], [1.12936866e+00], [1.14043659e+00], [1.15161300e+00], [1.16289893e+00], [1.17429547e+00], [1.18580369e+00], [1.19742469e+00], [1.20915959e+00], [1.22100948e+00], [1.23297551e+00], [1.24505880e+00], [1.25726051e+00], [1.26958180e+00], [1.28202384e+00], [1.29458781e+00], [1.30727491e+00], [1.32008634e+00], [1.33302333e+00], [1.34608710e+00], [1.35927890e+00], [1.37259997e+00], [1.38605160e+00], [1.39963505e+00], [1.41335162e+00], [1.42720262e+00], [1.44118936e+00], [1.45531317e+00], [1.46957539e+00], [1.48397738e+00], [1.49852052e+00], [1.51320618e+00], [1.52803575e+00], [1.54301067e+00], [1.55813233e+00], [1.57340219e+00], [1.58882170e+00], [1.60439232e+00], [1.62011553e+00], [1.63599283e+00], [1.65202573e+00], [1.66821575e+00], [1.68456444e+00], [1.70107335e+00], [1.71774404e+00], [1.73457811e+00], [1.75157716e+00], [1.76874280e+00], [1.78607666e+00], [1.80358039e+00], [1.82125567e+00], [1.83910416e+00], [1.85712757e+00], [1.87532761e+00], [1.89370601e+00], [1.91226453e+00], [1.93100491e+00], [1.94992896e+00], [1.96903846e+00], [1.98833524e+00], [2.00782113e+00], [2.02749798e+00], [2.04736767e+00], [2.06743208e+00], [2.08769312e+00], [2.10815273e+00], [2.12881284e+00], [2.14967542e+00], [2.17074246e+00], [2.19201595e+00], [2.21349793e+00], [2.23519044e+00], [2.25709553e+00], [2.27921529e+00], [2.30155183e+00], [2.32410727e+00], [2.34688376e+00], [2.36988345e+00], [2.39310855e+00], [2.41656125e+00], [2.44024380e+00], [2.46415843e+00], [2.48830743e+00], [2.51269309e+00], [2.53731774e+00], [2.56218370e+00], [2.58729336e+00], [2.61264909e+00], [2.63825331e+00], [2.66410846e+00], [2.69021699e+00], [2.71658138e+00], [2.74320415e+00], [2.77008782e+00], [2.79723496e+00], [2.82464814e+00], [2.85232997e+00], [2.88028309e+00], [2.90851015e+00], [2.93701383e+00], [2.96579686e+00], [2.99486196e+00], [3.02421191e+00], [3.05384948e+00], [3.08377751e+00], [3.11399883e+00], [3.14451633e+00], [3.17533290e+00], [3.20645147e+00], [3.23787501e+00], [3.26960650e+00], [3.30164897e+00], [3.33400545e+00], [3.36667903e+00], [3.39967282e+00], [3.43298995e+00], [3.46663358e+00], [3.50060693e+00], [3.53491322e+00], [3.56955572e+00], [3.60453771e+00], [3.63986254e+00], [3.67553354e+00], [3.71155413e+00], [3.74792772e+00], [3.78465778e+00], [3.82174780e+00], [3.85920130e+00], [3.89702184e+00], [3.93521304e+00], [3.97377851e+00], [4.01272192e+00], [4.05204699e+00], [4.09175744e+00], [4.13185706e+00], [4.17234966e+00], [4.21323909e+00], [4.25452925e+00], [4.29622405e+00], [4.33832746e+00], [4.38084349e+00], [4.42377618e+00], [4.46712961e+00], [4.51090791e+00], [4.55511525e+00], [4.59975582e+00], [4.64483387e+00], [4.69035369e+00], [4.73631961e+00], [4.78273599e+00], [4.82960727e+00], [4.87693788e+00], [4.92473235e+00], [4.97299520e+00], [5.02173103e+00], [5.07094448e+00], [5.12064022e+00], [5.17082299e+00], [5.22149755e+00], [5.27266873e+00], [5.32434138e+00], [5.37652044e+00], [5.42921086e+00], [5.48241764e+00], [5.53614586e+00], [5.59040062e+00], [5.64518709e+00], [5.70051046e+00], [5.75637601e+00], [5.81278904e+00], [5.86975493e+00], [5.92727909e+00], [5.98536699e+00], [6.04402416e+00], [6.10325618e+00], [6.16306867e+00], [6.22346733e+00], [6.28445791e+00], [6.34604619e+00], [6.40823805e+00], [6.47103940e+00], [6.53445620e+00], [6.59849449e+00], [6.66316037e+00], [6.72845997e+00], [6.79439952e+00], [6.86098528e+00], [6.92822359e+00], [6.99612084e+00], [7.06468349e+00], [7.13391806e+00], [7.20383114e+00], [7.27442937e+00], [7.34571947e+00], [7.41770822e+00], [7.49040246e+00], [7.56380912e+00], [7.63793516e+00], [7.71278765e+00], [7.78837370e+00], [7.86470050e+00], [7.94177531e+00], [8.01960547e+00], [8.09819836e+00], [8.17756147e+00], [8.25770235e+00], [8.33862861e+00], [8.42034796e+00], [8.50286817e+00], [8.58619708e+00], [8.67034263e+00], [8.75531280e+00], [8.84111570e+00], [8.92775947e+00], [9.01525235e+00], [9.10360268e+00], [9.19281884e+00], [9.28290934e+00], [9.37388273e+00], [9.46574766e+00], [9.55851288e+00], [9.65218721e+00], [9.74677956e+00], [9.84229892e+00], [9.93875437e+00], [1.00361551e+01], [1.01345104e+01], [1.02338295e+01], [1.03341220e+01], [1.04353974e+01], [1.05376653e+01], [1.06409354e+01], [1.07452175e+01], [1.08505217e+01], [1.09568578e+01], [1.10642361e+01], [1.11726666e+01], [1.12821598e+01], [1.13927260e+01], [1.15043758e+01], [1.16171198e+01], [1.17309686e+01], [1.18459332e+01], [1.19620245e+01], [1.20792535e+01], [1.21976313e+01], [1.23171692e+01], [1.24378786e+01], [1.25597710e+01], [1.26828579e+01], [1.28071511e+01], [1.29326624e+01], [1.30594037e+01], [1.31873871e+01], [1.33166247e+01], [1.34471289e+01], [1.35789120e+01], [1.37119867e+01], [1.38463654e+01], [1.39820611e+01], [1.41190866e+01], [1.42574550e+01], [1.43971794e+01], [1.45382731e+01], [1.46807495e+01], [1.48246222e+01], [1.49699049e+01], [1.51166114e+01], [1.52647556e+01], [1.54143516e+01], [1.55654137e+01], [1.57179562e+01], [1.58719937e+01], [1.60275407e+01], [1.61846121e+01], [1.63432228e+01], [1.65033879e+01], [1.66651227e+01], [1.68284424e+01], [1.69933627e+01], [1.71598993e+01], [1.73280679e+01], [1.74978846e+01], [1.76693655e+01], [1.78425269e+01], [1.80173854e+01], [1.81939574e+01], [1.83722599e+01], [1.85523098e+01], [1.87341241e+01], [1.89177203e+01], [1.91031157e+01], [1.92903280e+01], [1.94793751e+01], [1.96702747e+01], [1.98630453e+01], [2.00577050e+01], [2.02542724e+01], [2.04527661e+01], [2.06532051e+01], [2.08556085e+01], [2.10599954e+01], [2.12663853e+01], [2.14747979e+01], [2.16852529e+01], [2.18977704e+01], [2.21123706e+01], [2.23290739e+01], [2.25479009e+01], [2.27688724e+01], [2.29920095e+01], [2.32173333e+01], [2.34448653e+01], [2.36746272e+01], [2.39066408e+01], [2.41409281e+01], [2.43775114e+01], [2.46164133e+01], [2.48576564e+01], [2.51012638e+01], [2.53472585e+01], [2.55956640e+01], [2.58465039e+01], [2.60998020e+01], [2.63555825e+01], [2.66138697e+01], [2.68746881e+01], [2.71380625e+01], [2.74040181e+01], [2.76725800e+01], [2.79437739e+01], [2.82176254e+01], [2.84941608e+01], [2.87734062e+01], [2.90553883e+01], [2.93401338e+01], [2.96276698e+01], [2.99180237e+01], [3.02112232e+01], [3.05072960e+01], [3.08062703e+01], [3.11081746e+01], [3.14130376e+01], [3.17208883e+01], [3.20317560e+01], [3.23456701e+01], [3.26626607e+01], [3.29827578e+01], [3.33059919e+01], [3.36323937e+01], [3.39619943e+01], [3.42948250e+01], [3.46309175e+01], [3.49703037e+01], [3.53130159e+01], [3.56590868e+01], [3.60085491e+01], [3.63614363e+01], [3.67177817e+01], [3.70776194e+01], [3.74409835e+01], [3.78079086e+01], [3.81784296e+01], [3.85525818e+01], [3.89304007e+01], [3.93119222e+01], [3.96971827e+01], [4.00862188e+01], [4.04790674e+01], [4.08757661e+01], [4.12763524e+01], [4.16808644e+01], [4.20893408e+01], [4.25018202e+01], [4.29183420e+01], [4.33389457e+01], [4.37636714e+01], [4.41925595e+01], [4.46256507e+01], [4.50629862e+01], [4.55046076e+01], [4.59505570e+01], [4.64008767e+01], [4.68556096e+01], [4.73147989e+01], [4.77784884e+01], [4.82467220e+01], [4.87195443e+01], [4.91970004e+01], [4.96791356e+01], [5.01659957e+01], [5.06576271e+01], [5.11540765e+01], [5.16553912e+01], [5.21616189e+01], [5.26728076e+01], [5.31890060e+01], [5.37102632e+01], [5.42366287e+01], [5.47681527e+01], [5.53048857e+01], [5.58468787e+01], [5.63941833e+01], [5.69468515e+01], [5.75049359e+01], [5.80684896e+01], [5.86375662e+01], [5.92122198e+01], [5.97925050e+01], [6.03784771e+01], [6.09701918e+01], [6.15677053e+01], [6.21710745e+01], [6.27803568e+01], [6.33956102e+01], [6.40168930e+01], [6.46442645e+01], [6.52777843e+01], [6.59175126e+01], [6.65635103e+01], [6.72158389e+01], [6.78745604e+01], [6.85397373e+01], [6.92114331e+01], [6.98897116e+01], [7.05746372e+01], [7.12662752e+01], [7.19646913e+01], [7.26699519e+01], [7.33821242e+01], [7.41012758e+01], [7.48274752e+01], [7.55607914e+01], [7.63012941e+01], [7.70490539e+01], [7.78041417e+01], [7.85666295e+01], [7.93365898e+01], [8.01140957e+01], [8.08992213e+01], [8.16920411e+01], [8.24926307e+01], [8.33010661e+01], [8.41174243e+01], [8.49417828e+01], [8.57742202e+01], [8.66148155e+01], [8.74636487e+01], [8.83208005e+01], [8.91863525e+01], [9.00603871e+01], [9.09429872e+01], [9.18342369e+01], [9.27342209e+01], [9.36430249e+01], [9.45607352e+01], [9.54874391e+01], [9.64232249e+01], [9.73681814e+01], [9.83223986e+01], [9.92859672e+01], [1.00258979e+02], [1.01241526e+02], [1.02233702e+02], [1.03235602e+02], [1.04247321e+02], [1.05268954e+02], [1.06300600e+02], [1.07342355e+02], [1.08394320e+02], [1.09456595e+02], [1.10529279e+02], [1.11612477e+02], [1.12706289e+02], [1.13810821e+02], [1.14926178e+02], [1.16052465e+02], [1.17189790e+02], [1.18338261e+02], [1.19497987e+02], [1.20669078e+02], [1.21851646e+02], [1.23045803e+02], [1.24251664e+02], [1.25469342e+02], [1.26698953e+02], [1.27940614e+02], [1.29194444e+02], [1.30460561e+02], [1.31739087e+02], [1.33030142e+02], [1.34333850e+02], [1.35650334e+02], [1.36979720e+02], [1.38322134e+02], [1.39677704e+02], [1.41046558e+02], [1.42428827e+02], [1.43824643e+02], [1.45234138e+02], [1.46657446e+02], [1.48094702e+02], [1.49546044e+02], [1.51011609e+02], [1.52491537e+02], [1.53985968e+02], [1.55495045e+02], [1.57018911e+02], [1.58557710e+02], [1.60111591e+02], [1.61680699e+02], [1.63265185e+02], [1.64865199e+02], [1.66480893e+02], [1.68112421e+02], [1.69759938e+02], [1.71423602e+02], [1.73103569e+02], [1.74800000e+02], [1.76513056e+02], [1.78242900e+02], [1.79989697e+02], [1.81753613e+02], [1.83534815e+02], [1.85333473e+02], [1.87149758e+02], [1.88983843e+02], [1.90835902e+02], [1.92706112e+02], [1.94594650e+02], [1.96501695e+02], [1.98427430e+02], [2.00372037e+02], [2.02335702e+02], [2.04318610e+02], [2.06320951e+02], [2.08342916e+02], [2.10384696e+02], [2.12446485e+02], [2.14528480e+02], [2.16630879e+02], [2.18753882e+02], [2.20897690e+02], [2.23062508e+02], [2.25248541e+02], [2.27455998e+02], [2.29685087e+02], [2.31936023e+02], [2.34209017e+02], [2.36504287e+02], [2.38822051e+02], [2.41162529e+02], [2.43525944e+02], [2.45912521e+02], [2.48322486e+02], [2.50756070e+02], [2.53213502e+02], [2.55695018e+02], [2.58200853e+02], [2.60731245e+02], [2.63286435e+02], [2.65866667e+02], [2.68472185e+02], [2.71103237e+02], [2.73760074e+02], [2.76442948e+02], [2.79152114e+02], [2.81887831e+02], [2.84650358e+02], [2.87439957e+02], [2.90256895e+02], [2.93101440e+02], [2.95973861e+02], [2.98874432e+02], [3.01803429e+02], [3.04761131e+02], [3.07747818e+02], [3.10763775e+02], [3.13809289e+02], [3.16884649e+02], [3.19990148e+02], [3.23126081e+02], [3.26292746e+02], [3.29490445e+02], [3.32719482e+02], [3.35980164e+02], [3.39272800e+02], [3.42597705e+02], [3.45955194e+02], [3.49345587e+02], [3.52769206e+02], [3.56226377e+02], [3.59717429e+02], [3.63242693e+02], [3.66802505e+02], [3.70397203e+02], [3.74027130e+02], [3.77692630e+02], [3.81394053e+02], [3.85131750e+02], [3.88906077e+02], [3.92717392e+02], [3.96566059e+02], [4.00452443e+02], [4.04376914e+02], [4.08339845e+02], [4.12341613e+02], [4.16382599e+02], [4.20463187e+02], [4.24583765e+02], [4.28744725e+02], [4.32946463e+02], [4.37189379e+02], [4.41473875e+02], [4.45800360e+02], [4.50169244e+02], [4.54580945e+02], [4.59035880e+02], [4.63534474e+02], [4.68077155e+02], [4.72664354e+02], [4.77296508e+02], [4.81974058e+02], [4.86697449e+02], [4.91467129e+02], [4.96283552e+02], [5.01147176e+02], [5.06058465e+02], [5.11017885e+02], [5.16025907e+02], [5.21083009e+02], [5.26189671e+02], [5.31346378e+02], [5.36553622e+02], [5.41811897e+02], [5.47121703e+02], [5.52483547e+02], [5.57897936e+02], [5.63365388e+02], [5.68886421e+02], [5.74461560e+02], [5.80091336e+02], [5.85776285e+02], [5.91516947e+02], [5.97313868e+02], [6.03167599e+02], [6.09078697e+02], [6.15047724e+02], [6.21075249e+02], [6.27161844e+02], [6.33308088e+02], [6.39514565e+02], [6.45781867e+02], [6.52110589e+02], [6.58501333e+02], [6.64954707e+02], [6.71471325e+02], [6.78051806e+02], [6.84696776e+02], [6.91406868e+02], [6.98182719e+02], [7.05024974e+02], [7.11934284e+02], [7.18911306e+02], [7.25956703e+02], [7.33071146e+02], [7.40255311e+02], [7.47509881e+02], [7.54835547e+02], [7.62233005e+02], [7.69702959e+02], [7.77246119e+02], [7.84863203e+02], [7.92554935e+02], [8.00322046e+02], [8.08165276e+02], [8.16085371e+02], [8.24083083e+02], [8.32159173e+02], [8.40314410e+02], [8.48549569e+02], [8.56865433e+02], [8.65262793e+02], [8.73742449e+02], [8.82305205e+02], [8.90951878e+02], [8.99683289e+02], [9.08500268e+02], [9.17403655e+02], [9.26394295e+02], [9.35473045e+02], [9.44640767e+02], [9.53898334e+02], [9.63246626e+02], [9.72686532e+02], [9.82218950e+02], [9.91844786e+02], [1.00156496e+03], [1.01138039e+03], [1.02129201e+03], [1.03130076e+03], [1.04140761e+03], [1.05161350e+03], [1.06191941e+03], [1.07232631e+03], [1.08283521e+03], [1.09344710e+03], [1.10416298e+03], [1.11498388e+03], [1.12591082e+03], [1.13694485e+03], [1.14808702e+03], [1.15933838e+03], [1.17070000e+03], [1.18217297e+03], [1.19375837e+03], [1.20545731e+03], [1.21727091e+03], [1.22920027e+03], [1.24124655e+03], [1.25341088e+03], [1.26569442e+03], [1.27809835e+03], [1.29062383e+03], [1.30327206e+03], [1.31604425e+03], [1.32894160e+03], [1.34196535e+03], [1.35511674e+03], [1.36839701e+03], [1.38180742e+03], [1.39534926e+03], [1.40902382e+03], [1.42283238e+03], [1.43677627e+03], [1.45085681e+03], [1.46507534e+03], [1.47943321e+03], [1.49393180e+03], [1.50857247e+03], [1.52335661e+03], [1.53828565e+03], [1.55336099e+03], [1.56858407e+03], [1.58395634e+03], [1.59947926e+03], [1.61515430e+03], [1.63098297e+03], [1.64696675e+03], [1.66310718e+03], [1.67940578e+03], [1.69586411e+03], [1.71248374e+03], [1.72926624e+03], [1.74621320e+03], [1.76332626e+03], [1.78060702e+03], [1.79805713e+03], [1.81567825e+03], [1.83347207e+03], [1.85144026e+03], [1.86958455e+03], [1.88790665e+03], [1.90640831e+03], [1.92509129e+03], [1.94395736e+03], [1.96300832e+03], [1.98224599e+03], [2.00167218e+03], [2.02128875e+03], [2.04109757e+03], [2.06110051e+03], [2.08129949e+03], [2.10169642e+03], [2.12229323e+03], [2.14309190e+03], [2.16409440e+03], [2.18530273e+03], [2.20671890e+03], [2.22834495e+03], [2.25018293e+03], [2.27223493e+03], [2.29450305e+03], [2.31698939e+03], [2.33969610e+03], [2.36262533e+03], [2.38577928e+03], [2.40916014e+03], [2.43277013e+03], [2.45661150e+03], [2.48068652e+03], [2.50499748e+03], [2.52954669e+03], [2.55433648e+03], [2.57936921e+03], [2.60464727e+03], [2.63017305e+03], [2.65594899e+03], [2.68197754e+03], [2.70826116e+03], [2.73480237e+03], [2.76160369e+03], [2.78866766e+03], [2.81599686e+03], [2.84359389e+03], [2.87146137e+03], [2.89960196e+03], [2.92801833e+03], [2.95671318e+03], [2.98568924e+03], [3.01494927e+03], [3.04449605e+03], [3.07433239e+03], [3.10446113e+03], [3.13488514e+03], [3.16560730e+03], [3.19663055e+03], [3.22795782e+03], [3.25959211e+03], [3.29153641e+03], [3.32379377e+03], [3.35636726e+03], [3.38925997e+03], [3.42247503e+03], [3.45601560e+03], [3.48988487e+03], [3.52408607e+03], [3.55862243e+03], [3.59349726e+03], [3.62871387e+03], [3.66427560e+03], [3.70018584e+03], [3.73644800e+03], [3.77306554e+03], [3.81004193e+03], [3.84738069e+03], [3.88508538e+03], [3.92315957e+03], [3.96160690e+03], [4.00043101e+03], [4.03963561e+03], [4.07922441e+03], [4.11920118e+03], [4.15956974e+03], [4.20033390e+03], [4.24149756e+03], [4.28306463e+03], [4.32503906e+03], [4.36742484e+03], [4.41022601e+03], [4.45344663e+03], [4.49709082e+03], [4.54116273e+03], [4.58566654e+03], [4.63060650e+03], [4.67598687e+03], [4.72181197e+03], [4.76808616e+03], [4.81481385e+03], [4.86199947e+03], [4.90964751e+03], [4.95776251e+03], [5.00634904e+03], [5.05541173e+03], [5.10495523e+03], [5.15498426e+03], [5.20550358e+03], [5.25651800e+03], [5.30803236e+03], [5.36005157e+03], [5.41258057e+03], [5.46562436e+03], [5.51918798e+03], [5.57327653e+03], [5.62789516e+03], [5.68304905e+03], [5.73874346e+03], [5.79498367e+03], [5.85177505e+03], [5.90912298e+03], [5.96703294e+03], [6.02551041e+03], [6.08456097e+03], [6.14419023e+03], [6.20440386e+03], [6.26520759e+03], [6.32660720e+03], [6.38860854e+03], [6.45121749e+03], [6.51444002e+03], [6.57828213e+03], [6.64274991e+03], [6.70784947e+03], [6.77358701e+03], [6.83996879e+03], [6.90700112e+03], [6.97469037e+03], [7.04304298e+03], [7.11206545e+03], [7.18176435e+03], [7.25214630e+03], [7.32321800e+03], [7.39498622e+03], [7.46745776e+03], [7.54063954e+03], [7.61453850e+03], [7.68916169e+03], [7.76451618e+03], [7.84060916e+03], [7.91744785e+03], [7.99503957e+03], [8.07339170e+03], [8.15251168e+03], [8.23240705e+03], [8.31308540e+03], [8.39455440e+03], [8.47682181e+03], [8.55989545e+03], [8.64378321e+03], [8.72849309e+03], [8.81403313e+03], [8.90041146e+03], [8.98763632e+03], [9.07571599e+03], [9.16465884e+03], [9.25447334e+03], [9.34516804e+03], [9.43675155e+03], [9.52923258e+03], [9.62261994e+03], [9.71692251e+03], [9.81214925e+03], [9.90830921e+03], [1.00054116e+04], [1.01034655e+04], [1.02024804e+04], [1.03024657e+04], [1.04034308e+04], [1.05053854e+04], [1.06083391e+04], [1.07123018e+04], [1.08172834e+04], [1.09232937e+04], [1.10303430e+04], [1.11384414e+04], [1.12475992e+04], [1.13578267e+04], [1.14691344e+04], [1.15815330e+04], [1.16950331e+04], [1.18096455e+04]])}
Plotting the simulation is a little bit more complicated than plotting the solution, as you cannot use a dedicated function. Instead, we will use the matplot library in the following way.
To see the consumption and asset history, we can use objects created by the simulation which contain the history of every agent in each of the simulation periods. These objects have the same naming as the tracked variables with a _hist ending. Thus, from the previous example, the history of assets and consumption are called $\texttt{aNrmNow_hist}$ and $\texttt{cNrmNow_hist}$.
Let's make a plot of the assets level and consumption level during the simulated periods. First, define the vectors of mean assets and consumption. Here, there is only one consumer, so we do not need to use a mean function (although it is done so here). However, if you want to plot the mean asset/consumption level for many agents, you will need to use this method.
periods = np.linspace(0, 1000, 1000)
asset_level = np.mean(Example_agent_2.history["aNrm"][0:1000], axis=1)
cons_level = np.mean(Example_agent_2.history["cNrm"][0:1000], axis=1)
plt.figure(figsize=(5, 5))
plt.plot(periods, asset_level, label="Assets level")
plt.plot(periods, cons_level, label="Consumption level")
plt.legend(loc=2)
plt.show()
Now, let's plot the mean asset and consumption increase:
increase_assets = asset_level[1:1000] / asset_level[0:999]
increase_cons = cons_level[1:1000] / cons_level[0:999]
plt.figure(figsize=(5, 5))
plt.plot(periods[1:1000], increase_assets, label="Assets increase")
plt.plot(periods[1:1000], increase_cons, label="Consumption increase")
plt.legend(loc=2)
plt.show()
Congratulations! You've just learned the basics of the agent-type class in HARK. It is time for some exercises:
Define a dictionary and then use it to create the agent-type object with the parameters:
Assume no survival uncertainty and income growth factor 1.01
# Write your solution here
# fill the dictionary and then use it to create the object
# First_dictionary = {
# 'CRRA' : ,
# 'DiscFac' : ,
# 'Rfree' : ,
# 'cycles' : ,
# 'LivPrb' : [],
# 'PermGroFac' : [],
# }
# Exercise_agent =
Solution: click on the box on the left to expand the solution
# Solution
First_dictionary = {
"CRRA": 2.0,
"DiscFac": 0.96,
"Rfree": 1.05,
"cycles": 0,
"LivPrb": [1.0],
"PermGroFac": [1.0],
}
Exercise_agent = PerfForesightConsumerType(**First_dictionary)
# Write your solution here, use methods from "solving the model" subsection
Solution: click on the box on the left to expand the solution
# Solution
Exercise_agent.solve()
min_v = Exercise_agent.solution[0].mNrmMin
max_v = -Exercise_agent.solution[0].mNrmMin
print("Value function")
plot_funcs([Exercise_agent.solution[0].vFunc], min_v, max_v)
Value function
Next prepare the simulation. Assume that there exsists the initial assets and income heterogenity. Assume, the initial income and assets distributions are log-normal, have mean 1 and std 1. Simulate 1000 agents for 1000 periods.
Add the new parameters to the object:
# Write your solution here.
# Fill the dictionary
# Simulation_dictionary = { 'AgentCount': ,
# 'aNrmInitMean' : ,
# 'aNrmInitStd' : ,
# 'pLvlInitMean' : ,
# 'pLvlInitStd' : ,
# 'PermGroFacAgg' : 1.0, #assume no income aggregate growth
# 'T_cycle' : 1, #assume forward time flow
# 'T_sim' : ,
# 'T_age' : None #assume immortal agents
# }
# for key,value in Simulation_dictionary.items():
# setattr(Exercise_agent,key,value)
Solution: click on the box on the left to expand the solution
# Solution
Simulation_dictionary = {
"AgentCount": 1000,
"aNrmInitMean": 1.0,
"aNrmInitStd": 1.0,
"pLvlInitMean": 1.0,
"pLvlInitStd": 1.0,
"PermGroFacAgg": 1.0,
"T_cycle": 1,
"T_sim": 1000,
"T_age": None,
}
for key, value in Simulation_dictionary.items():
setattr(Exercise_agent, key, value)
# Write your solution here. Use the commands from "simulation" subsection, track consumption values
Solution: click on the box on the left to expand the solution
# Solution
Exercise_agent.track_vars = ["aNrm", "cNrm"]
Exercise_agent.initialize_sim()
Exercise_agent.simulate()
{'aNrm': array([[1.98852329e+01, 2.43139510e+00, 3.80130444e+00, ..., 2.17778682e+00, 9.03301714e+00, 1.32631458e+00], [2.00444516e+01, 2.52093985e+00, 3.89631773e+00, ..., 2.26631919e+00, 9.14891491e+00, 1.41144796e+00], [2.02043060e+01, 2.61084205e+00, 3.99171031e+00, ..., 2.35520497e+00, 9.26527533e+00, 1.49692118e+00], ..., [2.09754758e+03, 1.17091038e+03, 1.24363989e+03, ..., 1.15744613e+03, 1.52139540e+03, 1.11224084e+03], [2.10600062e+03, 1.17566438e+03, 1.24868421e+03, ..., 1.16214638e+03, 1.52754850e+03, 1.11676063e+03], [2.11448741e+03, 1.18043736e+03, 1.25374868e+03, ..., 1.16686539e+03, 1.53372616e+03, 1.12129847e+03]]), 'cNrm': array([[ 1.82774668, 1.0279216 , 1.09069793, ..., 1.01629996, 1.33044205, 0.9772811 ], [ 1.83504291, 1.03202501, 1.09505193, ..., 1.02035697, 1.33575309, 0.98118235], [ 1.84236826, 1.03614479, 1.09942331, ..., 1.02443018, 1.34108532, 0.98509918], ..., [97.03697611, 54.57366942, 57.90651123, ..., 53.9566678 , 70.6347045 , 51.88512758], [97.42433815, 54.79152215, 58.13766833, ..., 54.17205751, 70.91667128, 52.09224791], [97.8132465 , 55.01024452, 58.36974818, ..., 54.38830704, 71.19976365, 52.30019505]])}
Plot mean consumption level and consumption increase:
# Write your solution here.
# Firstly prepare the vectors which you would like to plot:
# periods= np.linspace(0,1000,1000)
# cons_level = np.mean(Exercise_agent.cNrmNow_hist[0:1000], axis = 1)
# increase_cons = cons_level[1:1000]/cons_level[0:999]
# next plot your solution
Solution: click on the box on the left to expand the solution
# Solution
periods = np.linspace(0, 1000, 1000)
cons_level = np.mean(Exercise_agent.history["cNrm"][0:1000], axis=1)
increase_cons = cons_level[1:1000] / cons_level[0:999]
plt.figure(figsize=(5, 5))
plt.plot(periods, cons_level, label="Consumption level")
plt.legend(loc=2)
plt.show()
plt.figure(figsize=(5, 5))
plt.plot(periods[1:1000], increase_cons, label="Consumption increase")
plt.legend(loc=2)
plt.show()
In this part we focus on more complicated cases of the deterministic agent model.
In the previous example survival probability (in the code LivPrb) and income increase factor (in the code PermGroFac) were stable and set to 1. However, if you want to build deterministic life-cycle model you need to add a age-dependent survival probability or income growth.
Consumer problem in this setting is:
\begin{eqnarray*} V_t(M_t,Y_t) &=& \max_{C_t}~U(C_t) + \beta \pi_t V_{t+1}(M_{t+1},Y_{t+1}), \\ & s.t. & \\ %A_t &=& M_t - C_t, \\ M_{t+1} &=& R (M_{t}-C_{t}) + Y_{t+1}, \\ Y_{t+1} &=& \Gamma_{t+1} Y_t, \\ \end{eqnarray*}Where $Y_t$ is an age-dependent income, $\pi_t$ is a survival probability and $\Gamma_{t+1}$ is an income growth rate. Also $\pi_{T+1} =0$
While it does not reduce the computational complexity of the problem (as permanent income is deterministic, given its initial condition $Y_0$), HARK represents this problem with normalized variables (represented in lower case), dividing all real variables by permanent income $Y_t$ and utility levels by $Y_t^{1-\rho}$. The Bellman form of the model thus reduces to:
\begin{eqnarray*} v_t(m_t) &=& \max_{c_t}~U(c_t) ~+ \beta_{t+1}\pi_{t+1} \Gamma_{t+1}^{1-\rho} v_{t+1}(m_{t+1}), \\ & s.t. & \\ a_t &=& m_t - c_t, \\ m_{t+1} &=& R / \Gamma_{t+1} a_t + 1. \end{eqnarray*}To solve this problem we need to study the cycles parameter more carefully. There is a notebook dedicated to solving and simulating life-cycle models which can be found here: Cycles_tutorial.
$\texttt{plot_funcs()}$ enables to plot many functions at the same graph. You need to declare them as vector of functions.
To see this, just follow an example. We plot the consumption functions for each age $t$ of the consumer.
To get better access to the consumption functions, you can use $\texttt{unpack('cFunc')}$ method, which will create the attribute $\texttt{cFunc}$ of the object (so you do not have to use it is as a solution attribute).
We illustrate this with the solution for "Exercise_agent_3". Recall that this agent was given a different time preference value ($\beta = .95$). Here, we also changed the length of the life-cycle of this agent to $10$ periods.
Example_agent_3.cycles = 1
Example_agent_3.LivPrb = [0.99, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, 0.92, 0.91, 0.90]
Example_agent_3.PermGroFac = [1.01, 1.01, 1.01, 1.02, 1.00, 0.99, 0.5, 1.0, 1.0, 1.0]
Example_agent_3.solve()
Example_agent_3.unpack("cFunc")
Next, we set the minimal value of the gird such that at least one of the consumption functions is defined.
min_v = min(Example_agent_3.solution[t].mNrmMin for t in range(11))
max_v = -min_v
print("Consumption functions")
plot_funcs(Example_agent_3.cFunc[:], min_v, max_v)
Consumption functions
If you want to compare a few functions (eg. value functions), you can also construct the vector by yourself, for example:
print("Value functions")
plot_funcs(
[
Example_agent_3.solution[0].vFunc,
Example_agent_3.solution[5].vFunc,
Example_agent_3.solution[9].vFunc,
],
min_v,
max_v,
)
Value functions
Here we present more advanced simulation techniques with the mortal agents and income dynamics.
We will also present how to plot the distribution of assets among the agents.
First, as in the part 1 of the tutorial, you need to define the simulation dictionary. However, you need to be careful with T_age parameter: because a maximal lifespan is 11 (T=10), T_age is set to 10, to ensure that all agents die after this age.
For the rest of the parameters, we set the number of consumers alive in each period to 1000. Initial asset level is near 0 (log of -10). The initial income level is given by the log-normal distribution with mean 0 and std 1. We set the rest of parameters as in the previous example.
Simulation_dictionary = {
"AgentCount": 1000,
"aNrmInitMean": -10.0,
"aNrmInitStd": 0.0,
"pLvlInitMean": 0.0,
"pLvlInitStd": 1.0,
"PermGroFacAgg": 1.0,
"T_cycle": 1,
"T_sim": 200,
"T_age": 10,
}
for key, value in Simulation_dictionary.items():
setattr(Example_agent_3, key, value)
Next, we simulate the economy and plot the mean asset level. However, be careful! $\texttt{aNrmNow}$ gives the asset levels normalized by the income. To get the original asset level we need to use $\texttt{aLvlNow}$ (unfortunately, cLvlNow is not implemented).
Example_agent_3.track_vars = ["aNrm", "cNrm", "aLvl"]
Example_agent_3.initialize_sim()
Example_agent_3.simulate()
periods = np.linspace(0, 200, 200)
assets_level = np.mean(Example_agent_3.history["aLvl"][0:200], axis=1)
plt.figure(figsize=(5, 5))
plt.plot(periods, assets_level, label="assets level")
plt.legend(loc=2)
plt.show()
As you can see, for the first 10 periods the asset level much more fluctuate. It is because in the first periods the agents which were born in period 0 strictly dominate the population (as only a small fraction die in the first periods of life).
You can simply cut the first observations, to get asset levels for more balanced population.
after_burnout = np.mean(Example_agent_3.history["aLvl"][10:200], axis=1)
plt.figure(figsize=(5, 5))
plt.plot(periods[10:200], after_burnout, label="assets level")
plt.legend(loc=2)
plt.show()
When you plot similar simulations, often the main interest is not to get exact assets/consumption levels during the simulation but rather a general distribution of assets.
In our case, we plot the asset distribution.
First, get one vector of the asset levels:
sim_wealth = np.reshape(Example_agent_3.history["aLvl"], -1)
Next, we plot simple histogram of assets level using a standard hist function from matplotlib library
print("Wealth distribution histogram")
n, bins, patches = plt.hist(sim_wealth, 100, density=True, range=[0.0, 10.0])
Wealth distribution histogram
With HARK, you can also easily plot the Lorenz curve. To do so import some HARK utilities which help us plot Lorenz curve:
from HARK.utilities import get_lorenz_shares
Then, use $\texttt{get_lorenz_shares}$ to plot the Lornez curve.
pctiles = np.linspace(0.001, 0.999, 15)
# SCF_Lorenz_points = get_lorenz_shares(SCF_wealth,weights=SCF_weights,percentiles=pctiles)
sim_Lorenz_points = get_lorenz_shares(sim_wealth, percentiles=pctiles)
plt.figure(figsize=(5, 5))
plt.title("Lorenz curve")
plt.plot(pctiles, sim_Lorenz_points, "-b", label="Lorenz curve")
plt.plot(pctiles, pctiles, "g-.", label="45 Degree")
plt.xlabel("Percentile of net worth")
plt.ylabel("Cumulative share of wealth")
plt.legend(loc=2)
plt.ylim([0, 1])
plt.show()
Let's make a model with a little more realistic assumptions.
In files 'life_table.csv' you find the death-probablities for Americans in age 25-105 in 2017 from Human Mortality Database. The age-dependent income for American males in file 'productivity_profile.csv' are deduced from Heathcote et al. (2010). Try to build a model with this data, assuming additionaly CRRA parameter to be 2.0, discount rate set to 0.99 and interest rate set to 1.05. Moreover, assume that initial income is given by log-normal distribution with mean 0 and std 0.05. Assume that initial asset is near 0 for all agents.
Do the following tasks:
# Write your solution here
# Firstly import data, you can use this part of code (however, there are other ways to do this)
import sys
import os
sys.path.insert(0, os.path.abspath(".."))
prob_dead = np.genfromtxt("life_table.csv", delimiter=",", skip_header=1)
prob_surv = 1 - prob_dead
# The HARK argument need to be a list, thus convert it from numpy array
prob_surv_list = np.ndarray.tolist(prob_surv[:79])
income_profile = np.genfromtxt("productivity_profile.csv", delimiter=",", skip_header=1)
income_profile_list = np.ndarray.tolist(income_profile[:79])
# Continue your solution
Solution: click on the box on the left to expand the solution
import sys
import os
sys.path.insert(0, os.path.abspath(".."))
prob_dead = np.genfromtxt("life_table.csv", delimiter=",", skip_header=1)
prob_surv = 1 - prob_dead
prob_surv_list = np.ndarray.tolist(prob_surv[:79])
income_profile = np.genfromtxt("productivity_profile.csv", delimiter=",", skip_header=1)
income_profile_list = np.ndarray.tolist(income_profile[:79])
Ex_dictionary = {
"CRRA": 2.0,
"Rfree": 1.05,
"DiscFac": 0.99,
"LivPrb": prob_surv_list,
"PermGroFac": income_profile_list,
"cycles": 1,
"T_cycle": 79,
}
Ex_agent = PerfForesightConsumerType(**Ex_dictionary)
Ex_agent.solve()
Ex_agent.unpack("cFunc")
min_v = min(Ex_agent.solution[t].mNrmMin for t in range(11))
max_v = -min_v
print("Consumption functions")
plot_funcs(Ex_agent.cFunc[:], min_v, max_v)
Simulation_dictionary = {
"AgentCount": 1000,
"aNrmInitMean": -10.0,
"aNrmInitStd": 0.0,
"pLvlInitMean": 0.0,
"pLvlInitStd": 0.05,
"PermGroFacAgg": 1.0,
"T_cycle": 79,
"T_sim": 2000,
"T_age": 80,
"BoroCnstArt": 0.0,
}
for key, value in Simulation_dictionary.items():
setattr(Ex_agent, key, value)
Ex_agent.track_vars = ["aNrm", "cNrm", "aLvl"]
Ex_agent.initialize_sim()
Ex_agent.simulate()
sim_wealth = np.reshape(Ex_agent.history["aLvl"], -1)
print("Wealth distribution histogram")
n, bins, patches = plt.hist(sim_wealth, 50, density=True, range=[-1.0, 2.0])
pctiles = np.linspace(0.001, 0.999, 15)
# SCF_Lorenz_points = get_lorenz_shares(SCF_wealth,weights=SCF_weights,percentiles=pctiles)
sim_Lorenz_points = get_lorenz_shares(sim_wealth, percentiles=pctiles)
plt.figure(figsize=(5, 5))
plt.title("Lorenz curve")
plt.plot(pctiles, sim_Lorenz_points, "-b", label="Lorenz curve")
plt.plot(pctiles, pctiles, "g-.", label="45 Degree")
plt.xlabel("Percentile of net worth")
plt.ylabel("Cumulative share of wealth")
plt.legend(loc=2)
plt.ylim([0, 1])
plt.show()
Consumption functions
Wealth distribution histogram