Question

In: Electrical Engineering

MATLAB Question Simulate 10,000 trading interactions of 100 people trading between each other. Interactions are random...

MATLAB Question

Simulate 10,000 trading interactions of 100 people trading between each other. Interactions are random and between 2 randomly chosen people. Each person starts with $100. In each interaction one person makes $1 and the other loses $1 with 50% chance. Find the distribution of wealth (money per person) after 10,000 trading interactions.

Solutions

Expert Solution

Hello,
          Please find the answer attached as under. Please give a thumbs up rating if you find the answer useful! Have a rocking day ahead!

************ Matlab Coding ***********

%% 100 people with 100 dollars each
money = 100*ones(1,100);
%% generating random pair of people for trading
n = 10000;
person1 = randi([1 100],1,n);
person2 = randi([1 100],1,n);
%% picking 1 person to win, at random, between person 1 and person 2
win = randi([1 2],1,n);
%% playing the game
for i=1:n
    p1 = person1(i);
    p2 = person2(i);
    if(win(i)==1)
        money(p1) = money(p1) + 1;
        money(p2) = money(p2) - 1;
    else
        money(p1) = money(p1) - 1;
        money(p2) = money(p2) + 1;
    end
end
%% plotting the distribution
histogram(money);xlabel('Money');ylabel('Frequency');
title('Distribution of money after 10,000 tradings')

********** Output ************

*****************************************************************
PS: Please do not forget the thumbs up!


Related Solutions

1. (a) Simulate a random sample of size 100 from the exponential distribution with the rate...
1. (a) Simulate a random sample of size 100 from the exponential distribution with the rate parameter λ = 10. Then make a histogram of the simulated data. (b) We use the simulated data as a data set to construct the log-likelihood function as an R function. We will find the MEL of the value λ = 10. Choose the appropriate range for the parameter λ, then make a plot of the log-likelihood function. (c) Use R function ‘optim‘ to...
Question: include the MATLAB output and commands used with each problem Generate two random 10 ×...
Question: include the MATLAB output and commands used with each problem Generate two random 10 × 10 matrices with numbers between -10 and 10. This can be done with >> A = randi([-10,10],10,10) >> B = randi([-10,10],10,10) 1.     with MATLAB to determi whether A and B are invertible matrices . 2.     If A is invertible, use MATLAB to show that A-1A = I 3.     Determi whether (AB)-1 = B-1A-1 4.     Determin whether (AT)-1 = (A-1)T 5.     Determe whether (A3)-1 = (A-1)3 6.     Determi whether (A +...
When two hydrogen atoms approach each other to form a chemical bond, different interactions occur between...
When two hydrogen atoms approach each other to form a chemical bond, different interactions occur between the atoms. Identify the correct statements with respect to the interactions involved in the formation of chemical bond. Check all that apply. When two atoms of H approach each other, each electron repels the other nucleus. When two atoms of H approach each other, each electron is attracted by the other nucleus. When two atoms of H are infinitely far apart, they show attractive...
To generate 100 random numbers between 1-100 in a randomData.txt file To read the 100 random...
To generate 100 random numbers between 1-100 in a randomData.txt file To read the 100 random numbers from randomData.txt and store them in an array Print the data in the array Find the smallest and the largest of the random numbers and their array position Insert an element of value100 in the 51th position of the array Delete all the elements of the array having values between 50-80 and print the residual array Sort the data in the final array(residual)...
In a study of people first getting acquainted with each other, researchers examined the relationship between...
In a study of people first getting acquainted with each other, researchers examined the relationship between the amount of self-disclosure and how much that person likes their partner. Here are the results: Person Partner's Self Disclosure Liking for Partner 1 8 7 2 7 9 3 10 6 4 3 7 5 1 4 First, state the null and alternative hypothesis. How much of the variance in liking for a partner explained by the amount of self-disclosure? Should a person...
Exhibit 9-6 A random sample of 100 people was taken. Eighty of the people in the...
Exhibit 9-6 A random sample of 100 people was taken. Eighty of the people in the sample favored Candidate A. We are interested in determining whether or not the proportion of the population in favor of Candidate A is significantly more than 75%. 32. Refer to Exhibit 9-6. The test statistic is a. 0.80 b. 0.05 c. 1.25 d. 2.00 33. Refer to Exhibit 9-6. The p -value is a. 0.2112 b. 0.05 c. 0.025 d. 0.0156 34. Refer to...
Exhibit 9-6 A random sample of 100 people was taken. Eighty of the people in the...
Exhibit 9-6 A random sample of 100 people was taken. Eighty of the people in the sample favored Candidate A. We are interested in determining whether or not the proportion of the population in favor of Candidate A is significantly more than 75%. 32. Refer to Exhibit 9-6. The test statistic is a. 0.80 b. 0.05 c. 1.25 d. 2.00 33. Refer to Exhibit 9-6. The p -value is a. 0.2112 b. 0.05 c. 0.025 d. 0.0156 34. Refer to...
Exhibit 9-6. a random sample of 100 people were taken. Eighty of the people in the...
Exhibit 9-6. a random sample of 100 people were taken. Eighty of the people in the sample favored candidate A. We are interested in determining whether or not the proportion of the population in favor of candidate A is significantly more than 75%. At a 0.05 level of significance it can be concluded that the proportion of the population in favor of candidate A is ____? Is it significantly greater than 75%, not significantly greater than 75%, significantly greater than...
Simulate 100 confidence intervals with a 90% confidence level. Choose a sample size between 30 and...
Simulate 100 confidence intervals with a 90% confidence level. Choose a sample size between 30 and 100. Look at your confidence intervals. Now increase the confidence level to 95%. Look at your confidence intervals. Finally, increase the confidence level to 99%. Look at your confidence intervals. How does the confidence level affect your confidence intervals?
The language is MATLAB Write a function that will generate three random integers, each in the...
The language is MATLAB Write a function that will generate three random integers, each in the inclusive range from 10 to 80. It will then return a string consisting of the three integers joined together, and also a character vector consisting of the three integers joined together. For example, if the random integers are 11, 29, and 76, the string that is returned will be "112976" and the character vector that is returned will be '112976'. I'm really confused on...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT