Question: For this assignment do not upload R code or output. Please summarize your findings on paper, scan and upload the pdf , for the following

For this assignment do not upload R code or output.
Please summarize your findings on paper, scan and upload the pdf, for the following two questions:
Use the pieces of code below to create the transition matrix for a Ladder Chain with k=10
states, and then run some experiments (run at least 10 times with new lists of random numbers) to estimate how far back in time would the Propp-Wilson algorithm have to start for at time 0
to be only one state occupied.
What would be your estimate if the Ladder Chain had k=100
states? Explain your reasoning for the answer.
Transition matrix
Copy
k=5
P=matrix(0,ncol=5, nrow=5)
P[1,1]=.5
P[k,k]=.5
for(i in 1:(k-1)){P[i,i+1]=.5
P[i+1,i]=.5}
Preparatory function
Copy
ppsi<- function(x,p){
cum_prob <- cumsum(p)
for (j in 1:length(p)){
if (x < cum_prob[j]){
j
break
}
}
return(j)
}
Update function
Copy
phi<-function(s,x){ppsi(x,P[s,])}
List of random numbers
Copy
n=10
Ul=runif(2^n)
Run the Propp-Wilson algorithm
Copy
for(j in 0:n){ts=1:k
Os=1:k
for(i in 2^j:1){
ts=lapply(ts,phi,x=Ul[i])
Os=cbind(Os,ts)}
print(Os)
if(length(unique(ts))==1){
X=unlist(unique(ts))
print(X)
break}
}
## Os ts
## [1,]12
## [2,]23
## [3,]34
## [4,]45
## [5,]55
## Os ts ts
## [1,]112
## [2,]212
## [3,]323
## [4,]434
## [5,]545
## Os ts ts ts ts
## [1,]11112
## [2,]21112
## [3,]32112
## [4,]43212
## [5,]54323
## Os ts ts ts ts ts ts ts ts
## [1,]123211112
## [2,]234321112
## [3,]345432112
## [4,]455432112
## [5,]555432112
## [1]2

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!