Question: # gym.R # Markov simulation P - matrix ( c ( 0 . 1 , 0 . 2 , 0 . 4 , 0 .

# gym.R
# Markov simulation
P - matrix(c(0.1,0.2,0.4,0.3,0.4,0,0.4,0.2,0.3,0.3,0,0.4,0.2,0.1,0.4,0.3),
nrow=4, byrow=TRUE)
lab - c("Aerobics","Massage","Weights","Yoga")
rownames(P)- lab
colnames(P)- lab
P
init - c((1)/(4),(1)/(4),(1)/(4),(1)/(4)) # initial distribution
states - c("a","m","w","y")
# simulate chain for 100 steps
simlist - markov(init,P,100,states)
simlist
table(simlist)/(100)
# gym.R # Markov simulation P < - matrix ( c ( 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!