Results 1 to 2 of 2

Math Help - Matlab - Distribution of money - HELP

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    2

    Matlab - Distribution of money - HELP

    Hi,
    Here is the problem:
    Suppose that N agents can exchange money in pairs. They are all assigned the same amount of money m0, and are then allowed to interact.
    At each step, a pair of agent i and j with money mi and mj is randomly chosen and a transaction takes place.
    After a random reassignment of money, we assume:
    mi'=E(mi+mj)
    mj'=(1-E)(mi+mj)
    Where E is a randon number between 0 and 1.
    (this reassignment ensures no debts after the transaction).

    QUESTION:
    Using Matlab, simulate this model and determine the distribution of money among the agents after the system has relaxed to an equilibrium state.
    Chose: N=100
    m0=1000

    If someone could help me on this, it would be grealty appreciated.
    Last edited by regg; December 4th 2009 at 03:15 PM. Reason: further study
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Nov 2009
    Posts
    2

    further study of the code

    So here is my code so far:

    clear all;
    M=1000*ones(100,1); %100 agents with 1000$ initially.
    T=input('enter a value for T:'); %the number of times that 2 agents are randomly picked and are allowed to interact.
    for i=1:1:T %loop from i=1 to i=T.
    x=randi([1 100],1); %agent 1 picked at step i.
    y=randi([1 100],1); %agent 2 picked at step i.
    R=rand; %generates a random number between 0 and 1
    if x==y;
    y=randi([1 100],1); %in case picking twice the same agent
    end
    P=M(x);
    Q=M(y);
    M(x)=R.*(P+Q); %such reassignment of money ensures no dept after transaction.
    M(y)=(1-R).*(P+Q);
    disp(' ')
    end
    for j=1:1:size(M);
    fprintf('%5.0f\t%5.0f\n',j,M(j));
    end
    Mf=sum(M,1); % Mf = total amount of money (~=100,000$)
    fprintf('Total amount of money:\n%5.0f\t%5.0f\n',Mf);
    C=sort(M);
    D=C(81:1:100);
    disp(' ')
    E=sum(D); % E = total amount of money among the 20 richest agents.
    fprintf('Amount of money among the 20 richest agents:\n%5.0f\t%5.0f\n',E);



    How can i plot the distribution of money after T pickings ?
    I'd guess a gaussian dist, what are the command in this case?
    where should I place it within the code?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 5
    Last Post: January 5th 2011, 09:16 PM
  2. Replies: 1
    Last Post: June 3rd 2010, 09:39 AM
  3. Money Distribution
    Posted in the Discrete Math Forum
    Replies: 3
    Last Post: February 6th 2010, 06:56 AM
  4. Money...
    Posted in the Math Puzzles Forum
    Replies: 3
    Last Post: August 12th 2009, 08:24 PM
  5. [SOLVED] money,money,money...
    Posted in the Statistics Forum
    Replies: 2
    Last Post: May 17th 2006, 04:44 AM

Search Tags


/mathhelpforum @mathhelpforum