spedygiorgio / markovchain

Easy Handling Discrete Time Markov Chains
https://spedygiorgio.github.io/markovchain/
Other
105 stars 39 forks source link

bug in states classification #59

Closed spedygiorgio closed 8 years ago

spedygiorgio commented 8 years ago

Dear Giorgio,

spring semester is coming and I am teaching the course on Markov Chains again, and so I decided to take another look at your package. I am impressed how much it has improved since last year!

However, I find the output of summary() now a bit strange, check the following example:

A <- structure(c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.3, 0.3, 0, 0, 0, 0, 0, 0.5, 0.7, 0.7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3, 0.4, 0, 0, 0, 0, 0, 0.4, 0, 0.5, 0, 0, 0, 0, 0, 0.6, 0.7, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 1), .Dim = c(8L, 8L), .Dimnames = list( c("1", "2", "3", "4", "5", "6", "7", "8"), c("1", "2", "3", "4", "5", "6", "7", "8"))) mchain <- new("markovchain", transitionMatrix=A) summary(mchain)

Output:

summary(mchain) Unnamed Markov chain Markov chain that is composed by: Closed classes: 3 4 8 Recurrent classes: {3,4},{5,6,7},{8} Transient classes: {1},{2},{5,6,7} The Markov chain is not irreducible The absorbing states are: 8

Class {5,6,7} is listed as both recurrent and transient, which are mutually exclusive by the standard definition (also employed in the vignette). In this case, the class is actually transient (eventually, the chain jumps from state 7 to 8, with 8 being an absorbing state). Is this a bug or have I overlooked something?

tskang commented 8 years ago

Fixed it.

summary(mchain) Unnamed Markov chain Markov chain that is composed by: Closed classes: 3 4 8 Recurrent classes: {3,4},{8} Transient classes: {1},{2},{5,6,7} The Markov chain is not irreducible The absorbing states are: 8

spedygiorgio commented 8 years ago

Seems closed at better analysis. Hope not to reopen :+1: