spedygiorgio / markovchain

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

Feature suggestion: check monotonicity #214

Open jstover79 opened 1 year ago

jstover79 commented 1 year ago

Given a Markov chain object (e.g. with a transition matrix), it would be nice to have a method that checks if it is a monotone transition matrix. Just for reference, in case this is an unfamiliar property, it means that row $i$ is stochastically dominated by row $j$ whenever $i < j$. Each row is of course s discrete probability distribution. Assume we have state space ${0,1,\ldots,k}$. Probability distribution $x$ is stochastically dominated by distribution $y$ if the $xm+x{m+1}+\cdots+x_k\leq ym+y{m+1}+\cdots+y_k$ for every value of $m$.

For example $x=(0.6,0.1,0.3)$ is stochastically dominated by $y=(0.5,0.2,0.3)$.

Monotonicity is interesting because it allows one to couple two copies of the chain so that one is always above the other.

Maybe there isn't demand for such a feature, but I just thought I'd try to suggest it. Please forgive me if it is inappropriate to suggest features here.

spedygiorgio commented 1 year ago

HI @jstover79 thank you for your message. Your FR is interesting, but currently I have little time to develop. Would you like to forward a pull request?

jstover79 commented 1 year ago

Thanks for the reply. I can try that. In fact, that would be a good chance for me to refresh my git skills. I did successfully push an edit to AOSP once, but it was a long time ago. I can code this up, but it probably just won't be the most efficient way to do so.

PietroZanotta commented 1 year ago

Hi @jstover79, I think that feature would be AMAZING. Is there any chance I can contribute to this?

jstover79 commented 1 year ago

@ScipioneParmigiano Please do. I have been meaning to sit down and try to do it, but I just haven't had the time to figure out how to properly propose the feature on the git project here. I'd love to try just to learn how, but don't want to mess anything up. It would be an easy method to code up, but I'm just not sure if it needs to be done in C++ or whatever. I can easily write an R script though. But carefully debugging it to make sure it handles all possible cases would need some care.