Re: [R] Limiting state probability for Markov chain

2015-04-28 Thread Jim Lemon
Hi Justin, As already noted, you want to compare two values in your "if" statement. I think you may want to do it like this: my_fun<-function(A,b) { for(j in 1:3) { x<-A; while((sum(x[j,])==1)) { x<-x%*%x; print(x); if(b%*%x[,j]==b[j]) break; } } } Jim Justin USHIZE RUTIKANGA wr

Re: [R] Limiting state probability for Markov chain

2015-04-28 Thread PIKAL Petr
you'd better to use C+ directly. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Justin > USHIZE RUTIKANGA > Sent: Tuesday, April 28, 2015 8:52 AM > To: r-help@r-project.org > Subject: [R] Limiting state probab

Re: [R] Limiting state probability for Markov chain

2015-04-28 Thread Duncan Murdoch
On 28/04/2015 2:52 AM, Justin USHIZE RUTIKANGA wrote: > Dear All, > > I am trying to determine the liming state probability . > my_fun<-function(A,b){ > for (j in 1:3){ > x<-A; > while ((sum(x[j,]) ==1) ) > { > x <- x%*%x; > print (x); > if ( b%*%x==b) > { > break; > }}} > } > A<-r

[R] Limiting state probability for Markov chain

2015-04-28 Thread Justin USHIZE RUTIKANGA
Dear All, I am trying to determine the liming state probability . my_fun<-function(A,b){ for (j in 1:3){ x<-A; while ((sum(x[j,]) ==1) ) { x <- x%*%x; print (x); if ( b%*%x==b) { break; }}} } A<-rbind(c(.5,.3,.2), c(.3,.3,.4),c(.1,.5,.4)) b <- matrix(data=c(1,0,0), nrow=1, ncol=3,