Minor update
This commit is contained in:
@@ -127,11 +127,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>
|
||||
@@ -173,7 +169,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>
|
||||
@@ -1335,7 +1331,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
|
||||
@@ -1406,9 +1402,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.
|
||||
@@ -1419,12 +1415,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 "default" -->
|
||||
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span><span style="color: #408080; font-style: italic">#!/usr/bin/env python</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">numpy</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">np</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.mlab</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">mlab</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">matplotlib.pyplot</span> <span style="color: #008000; font-weight: bold">as</span> <span style="color: #0000FF; font-weight: bold">plt</span>
|
||||
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">random</span>
|
||||
|
||||
<span style="color: #408080; font-style: italic"># initialize the rng with a seed</span>
|
||||
random<span style="color: #666666">.</span>seed()
|
||||
<span style="color: #408080; font-style: italic"># Hard coding of input parameters</span>
|
||||
Agents <span style="color: #666666">=</span> <span style="color: #666666">500</span>
|
||||
MCcounts <span style="color: #666666">=</span> <span style="color: #666666">1000</span>
|
||||
Transactions <span style="color: #666666">=</span> <span style="color: #666666">100000</span>
|
||||
startMoney <span style="color: #666666">=</span> <span style="color: #666666">1.0</span>
|
||||
Lambda <span style="color: #666666">=</span> <span style="color: #666666">0.0</span>
|
||||
FinancialAgents <span style="color: #666666">=</span> startMoney<span style="color: #666666">*</span>np<span style="color: #666666">.</span>ones(Agents)
|
||||
<span style="color: #008000; font-weight: bold">for</span> i <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span> (<span style="color: #666666">1</span>, MCcounts, <span style="color: #666666">1</span>):
|
||||
<span style="color: #008000; font-weight: bold">for</span> j <span style="color: #AA22FF; font-weight: bold">in</span> <span style="color: #008000">range</span> (<span style="color: #666666">1</span>, Transactions, <span style="color: #666666">1</span>):
|
||||
agent_i <span style="color: #666666">=</span> <span style="color: #008000">int</span>(Agents<span style="color: #666666">*</span>random<span style="color: #666666">.</span>random())
|
||||
agent_j <span style="color: #666666">=</span> <span style="color: #008000">int</span>(Agents<span style="color: #666666">*</span>random<span style="color: #666666">.</span>random())
|
||||
epsilon <span style="color: #666666">=</span> random<span style="color: #666666">.</span>random()
|
||||
<span style="color: #008000; font-weight: bold">if</span> agent_i <span style="color: #666666">!=</span> agent_j:
|
||||
m1 <span style="color: #666666">=</span> Lambda<span style="color: #666666">*</span>FinancialAgents[agent_i] <span style="color: #666666">+</span> (<span style="color: #666666">1-</span>Lambda)<span style="color: #666666">*</span>epsilon<span style="color: #666666">*</span>(FinancialAgents[agent_i] <span style="color: #666666">+</span> FinancialAgents[agent_j])
|
||||
m2 <span style="color: #666666">=</span> Lambda<span style="color: #666666">*</span>FinancialAgents[agent_j] <span style="color: #666666">+</span> (<span style="color: #666666">1-</span>Lambda)<span style="color: #666666">*</span>(<span style="color: #666666">1-</span>epsilon)<span style="color: #666666">*</span>(FinancialAgents[agent_i] <span style="color: #666666">+</span> FinancialAgents[agent_j])
|
||||
FinancialAgents[agent_i] <span style="color: #666666">=</span> m1
|
||||
FinancialAgents[agent_j] <span style="color: #666666">=</span> m2
|
||||
|
||||
<span style="color: #408080; font-style: italic"># the histogram of the data</span>
|
||||
n, bins, patches <span style="color: #666666">=</span> plt<span style="color: #666666">.</span>hist(FinancialAgents, <span style="color: #666666">50</span>, facecolor<span style="color: #666666">=</span><span style="color: #BA2121">'green'</span>)
|
||||
|
||||
plt<span style="color: #666666">.</span>xlabel(<span style="color: #BA2121">'$x$'</span>)
|
||||
plt<span style="color: #666666">.</span>ylabel(<span style="color: #BA2121">'Distribution of wealth'</span>)
|
||||
plt<span style="color: #666666">.</span>title(<span style="color: #BA2121">r'Money'</span>)
|
||||
plt<span style="color: #666666">.</span>axis([<span style="color: #666666">0</span>, <span style="color: #666666">10</span>, <span style="color: #666666">0</span>, <span style="color: #666666">500</span>])
|
||||
plt<span style="color: #666666">.</span>grid(<span style="color: #008000">True</span>)
|
||||
plt<span style="color: #666666">.</span>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.
|
||||
@@ -1477,7 +1506,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