Minor update
This commit is contained in:
@@ -122,11 +122,7 @@ div { text-align: justify; text-justify: inter-word; }
|
||||
None,
|
||||
'___sec35'),
|
||||
('Simulating financial transcations', 2, None, '___sec36'),
|
||||
('Project 4a): Simulation of Transactions', 3, None, '___sec37'),
|
||||
('Project 4b): Recognizing the distribution',
|
||||
3,
|
||||
None,
|
||||
'___sec38')]}
|
||||
('Simulation of Transactions', 3, None, '___sec37')]}
|
||||
end of tocinfo -->
|
||||
|
||||
<body>
|
||||
@@ -168,7 +164,7 @@ MathJax.Hub.Config({
|
||||
<center>[2] <b>Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University</b></center>
|
||||
<br>
|
||||
<p>
|
||||
<center><h4>May 9, 2018</h4></center> <!-- date -->
|
||||
<center><h4>May 11, 2018</h4></center> <!-- date -->
|
||||
<br>
|
||||
<p>
|
||||
<!-- !split --><br><br><br><br><br><br><br><br><br><br>
|
||||
@@ -1330,7 +1326,7 @@ Change <code>r</code> in the program and play around to make a better fit!
|
||||
<h2 id="___sec36">Simulating financial transcations </h2>
|
||||
|
||||
<p>
|
||||
The aim of this project is to simulate financial transactions among financial agents
|
||||
The aim here is to simulate financial transactions among financial agents
|
||||
using Monte Carlo methods. The final goal is to extract a distribution of income as function
|
||||
of the income \( m \). From Pareto's work (<a href="http://www.institutcoppet.org/2012/05/08/cours-deconomie-politique-1896-de-vilfredo-pareto" target="_blank">V. Pareto, 1897</a>) it is known from empirical studies
|
||||
that the higher end of the distribution of money follows a distribution
|
||||
@@ -1401,9 +1397,9 @@ exponentially decreases with \( m' \).
|
||||
We assume that we have \( N=500 \) agents. In each simulation, we need a sufficiently large number of transactions, say \( 10^7 \). Our aim is find the final equilibrium distribution \( w_m \). In order to do that we would need
|
||||
several runs of the above simulations, at least \( 10^3-10^4 \) runs (experiments).
|
||||
|
||||
<h3 id="___sec37">Project 4a): Simulation of Transactions </h3>
|
||||
<h3 id="___sec37">Simulation of Transactions </h3>
|
||||
|
||||
Your task is to first set up an algorithm which simulates the above transactions with an initial
|
||||
Our task is to first set up an algorithm which simulates the above transactions with an initial
|
||||
amount \( m_0 \).
|
||||
The challenge here is to figure out a Monte Carlo simulation based on the
|
||||
above equations.
|
||||
@@ -1414,12 +1410,45 @@ Your task is to first set up an algorithm which simulates the above transactions
|
||||
\( m,m+\Delta m \). The number of times you register this income, represents the value that enters the histogram.
|
||||
You will also need to find a criterion for when the equilibrium situation has been reached.
|
||||
|
||||
<h3 id="___sec38">Project 4b): Recognizing the distribution </h3>
|
||||
<p>
|
||||
|
||||
Make thereafter a plot of \( \log{(w_m)} \) as function of \( m \)
|
||||
and see if you get a straight line.
|
||||
Comment the result.
|
||||
<!-- code=python (!bc pycod) typeset with pygments style "perldoc" -->
|
||||
<div class="highlight" style="background: #eeeedd"><pre style="line-height: 125%"><span></span><span style="color: #228B22">#!/usr/bin/env python</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">numpy</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">np</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.mlab</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">mlab</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">matplotlib.pyplot</span> <span style="color: #8B008B; font-weight: bold">as</span> <span style="color: #008b45; text-decoration: underline">plt</span>
|
||||
<span style="color: #8B008B; font-weight: bold">import</span> <span style="color: #008b45; text-decoration: underline">random</span>
|
||||
|
||||
<span style="color: #228B22"># initialize the rng with a seed</span>
|
||||
random.seed()
|
||||
<span style="color: #228B22"># Hard coding of input parameters</span>
|
||||
Agents = <span style="color: #B452CD">500</span>
|
||||
MCcounts = <span style="color: #B452CD">1000</span>
|
||||
Transactions = <span style="color: #B452CD">100000</span>
|
||||
startMoney = <span style="color: #B452CD">1.0</span>
|
||||
Lambda = <span style="color: #B452CD">0.0</span>
|
||||
FinancialAgents = startMoney*np.ones(Agents)
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> i <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span> (<span style="color: #B452CD">1</span>, MCcounts, <span style="color: #B452CD">1</span>):
|
||||
<span style="color: #8B008B; font-weight: bold">for</span> j <span style="color: #8B008B">in</span> <span style="color: #658b00">range</span> (<span style="color: #B452CD">1</span>, Transactions, <span style="color: #B452CD">1</span>):
|
||||
agent_i = <span style="color: #658b00">int</span>(Agents*random.random())
|
||||
agent_j = <span style="color: #658b00">int</span>(Agents*random.random())
|
||||
epsilon = random.random()
|
||||
<span style="color: #8B008B; font-weight: bold">if</span> agent_i != agent_j:
|
||||
m1 = Lambda*FinancialAgents[agent_i] + (<span style="color: #B452CD">1</span>-Lambda)*epsilon*(FinancialAgents[agent_i] + FinancialAgents[agent_j])
|
||||
m2 = Lambda*FinancialAgents[agent_j] + (<span style="color: #B452CD">1</span>-Lambda)*(<span style="color: #B452CD">1</span>-epsilon)*(FinancialAgents[agent_i] + FinancialAgents[agent_j])
|
||||
FinancialAgents[agent_i] = m1
|
||||
FinancialAgents[agent_j] = m2
|
||||
|
||||
<span style="color: #228B22"># the histogram of the data</span>
|
||||
n, bins, patches = plt.hist(FinancialAgents, <span style="color: #B452CD">50</span>, facecolor=<span style="color: #CD5555">'green'</span>)
|
||||
|
||||
plt.xlabel(<span style="color: #CD5555">'$x$'</span>)
|
||||
plt.ylabel(<span style="color: #CD5555">'Distribution of wealth'</span>)
|
||||
plt.title(<span style="color: #CD5555">r'Money'</span>)
|
||||
plt.axis([<span style="color: #B452CD">0</span>, <span style="color: #B452CD">10</span>, <span style="color: #B452CD">0</span>, <span style="color: #B452CD">500</span>])
|
||||
plt.grid(<span style="color: #658b00">True</span>)
|
||||
plt.show()
|
||||
</pre></div>
|
||||
<p>
|
||||
We can then change our model to allow for a saving criterion, meaning that the agents save
|
||||
a fraction \( \lambda \) of the money they have before the transaction is made. The final distribution will then no longer be given by Gibbs distribution. It could also include a taxation on financial transactions.
|
||||
@@ -1472,7 +1501,6 @@ $$
|
||||
Extract a parametrization of the above curves, see for example <a href="http://www.sciencedirect.com/science/article/pii/S0378437104004327" target="_blank">Patriarca and collaborators</a> and see if you can parametrize the high-end tails of the distributions in terms of power laws. Comment your results.
|
||||
|
||||
<p>
|
||||
In the rest of this project we will follow the work of <a href="http://www.sciencedirect.com/science/article/pii/S0378437114006967" target="_blank">Goswami and Sen</a>.
|
||||
In the studies above the agents were selected randomly, irrespective of whether we allowed for
|
||||
saving or not during a transaction. What is often observed is that various agents tend to make preferences for for whom to interact with. We will now study the evolution of the distribution of wealth \( w_m \) by assuming that there is a likelihood
|
||||
$$
|
||||
|
||||
Reference in New Issue
Block a user