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
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
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
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,
4 matches
Mail list logo