Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In the previous two problems, the population, i.e. the number of balls in the urn, increases over time. A closely related but different scenario, called

In the previous two problems, the population, i.e. the number of balls in the urn, increases over

time. A closely related but different scenario, called the Moran process, deals with the dynamics of

different colors for a fixed number of balls.

Consider at time 0 an urn containing 20 balls, 10 of which are blue and the other 10 are red. In each

time step, we

(i) randomly sample one ball from the urn, b1, record its color, and then put it back to the urn;

(ii) randomly sample another one from the urn, b2, and put back to the urn a new ball of the same

color as b1 (so that b2 is replaced by b1).

The above two steps essentially amount to sampling two balls with replacement from the urn. By

chance, b1 and b2 may be the same ball, in which case b1 is simply replaced by itself. The point is

that the total number of balls (population size) in this process is kept at 20 across all time steps. Of

interest is whether one color will dominate the other color as time goes on.

(a) Write an R function MoranProc(n.steps, urn=rep(c("blue","red"),each=10)), where n.steps

is the maximum time step, and urn is the initial state of the urn with 10 blue balls and 10 red

balls. As in the previous two problems, the function should return p.red, a vector of length

(n.steps+1) that represents the proportion of red balls at the end of each time step.

Hints: To get you started, here is an outline that you should probably follow.

initialize p.red as a vector of length n.steps+1, with p.red[1] = 0.5.

for (i in 2:(n.steps+1)){

sample two elements from 1:20 with replacement, call it id

replace urn[id[2]] by urn[id[1]]

compute p.red[i]

}

return p.red

2

(b) Run MoranProc(n.steps = 1500) once and plot the sample path of p.red. In the plot, make

sure to

set the y-axis limit to c(0,1);

properly label the axes.

Does it seem to you that one color has dominated the other color?

(c) Repeat MoranProc(n.steps = 1500) 200 times and graph all sample paths in a single plot.

Briefly comment on the pattern in the graph.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions