Minor update
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
"<!-- Author: --> \n",
|
||||
"**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and National Superconducting Cyclotron Laboratory, Michigan State University\n",
|
||||
"\n",
|
||||
"Date: **May 9, 2018**\n",
|
||||
"Date: **May 11, 2018**\n",
|
||||
"\n",
|
||||
"Copyright 1999-2018, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license\n",
|
||||
"\n",
|
||||
@@ -1216,7 +1216,7 @@
|
||||
"\n",
|
||||
"## Simulating financial transcations\n",
|
||||
"\n",
|
||||
"The aim of this project is to simulate financial transactions among financial agents\n",
|
||||
"The aim here is to simulate financial transactions among financial agents\n",
|
||||
"using Monte Carlo methods. The final goal is to extract a distribution of income as function\n",
|
||||
"of the income $m$. From Pareto's work ([V. Pareto, 1897](http://www.institutcoppet.org/2012/05/08/cours-deconomie-politique-1896-de-vilfredo-pareto)) it is known from empirical studies\n",
|
||||
"that the higher end of the distribution of money follows a distribution"
|
||||
@@ -1344,9 +1344,9 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"### Project 4a): Simulation of Transactions\n",
|
||||
"### Simulation of Transactions\n",
|
||||
"\n",
|
||||
"Your task is to first set up an algorithm which simulates the above transactions with an initial\n",
|
||||
"Our task is to first set up an algorithm which simulates the above transactions with an initial\n",
|
||||
" amount $m_0$.\n",
|
||||
" The challenge here is to figure out a Monte Carlo simulation based on the\n",
|
||||
" above equations.\n",
|
||||
@@ -1355,14 +1355,58 @@
|
||||
" $w_m\\Delta m$. You will need to set up a value for the interval $\\Delta m$ (typically $0.01-0.05$).\n",
|
||||
" That means you need to account for the number of times you register an income in the interval\n",
|
||||
" $m,m+\\Delta m$. The number of times you register this income, represents the value that enters the histogram.\n",
|
||||
" You will also need to find a criterion for when the equilibrium situation has been reached.\n",
|
||||
" You will also need to find a criterion for when the equilibrium situation has been reached."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#!/usr/bin/env python\n",
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.mlab as mlab\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import random\n",
|
||||
"\n",
|
||||
"### Project 4b): Recognizing the distribution\n",
|
||||
"# initialize the rng with a seed\n",
|
||||
"random.seed()\n",
|
||||
"# Hard coding of input parameters\n",
|
||||
"Agents = 500\n",
|
||||
"MCcounts = 1000\n",
|
||||
"Transactions = 100000\n",
|
||||
"startMoney = 1.0\n",
|
||||
"Lambda = 0.0\n",
|
||||
"FinancialAgents = startMoney*np.ones(Agents)\n",
|
||||
"for i in range (1, MCcounts, 1):\n",
|
||||
" for j in range (1, Transactions, 1):\n",
|
||||
" agent_i = int(Agents*random.random())\n",
|
||||
" agent_j = int(Agents*random.random())\n",
|
||||
" epsilon = random.random()\n",
|
||||
" if agent_i != agent_j:\n",
|
||||
" m1 = Lambda*FinancialAgents[agent_i] + (1-Lambda)*epsilon*(FinancialAgents[agent_i] + FinancialAgents[agent_j])\n",
|
||||
" m2 = Lambda*FinancialAgents[agent_j] + (1-Lambda)*(1-epsilon)*(FinancialAgents[agent_i] + FinancialAgents[agent_j])\n",
|
||||
" FinancialAgents[agent_i] = m1\n",
|
||||
" FinancialAgents[agent_j] = m2\n",
|
||||
"\n",
|
||||
"Make thereafter a plot of $\\log{(w_m)}$ as function of $m$\n",
|
||||
" and see if you get a straight line.\n",
|
||||
" Comment the result.\n",
|
||||
"# the histogram of the data\n",
|
||||
"n, bins, patches = plt.hist(FinancialAgents, 50, facecolor='green')\n",
|
||||
"\n",
|
||||
"plt.xlabel('$x$')\n",
|
||||
"plt.ylabel('Distribution of wealth')\n",
|
||||
"plt.title(r'Money')\n",
|
||||
"plt.axis([0, 10, 0, 500])\n",
|
||||
"plt.grid(True)\n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We can then change our model to allow for a saving criterion, meaning that the agents save\n",
|
||||
" 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.\n",
|
||||
"\n",
|
||||
@@ -1452,7 +1496,6 @@
|
||||
" equilibrium distributions and compare these with the Gibbs distribution. Comment your results.\n",
|
||||
"Extract a parametrization of the above curves, see for example [Patriarca and collaborators](http://www.sciencedirect.com/science/article/pii/S0378437104004327) and see if you can parametrize the high-end tails of the distributions in terms of power laws. Comment your results.\n",
|
||||
"\n",
|
||||
"In the rest of this project we will follow the work of [Goswami and Sen](http://www.sciencedirect.com/science/article/pii/S0378437114006967). \n",
|
||||
"In the studies above the agents were selected randomly, irrespective of whether we allowed for\n",
|
||||
"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