Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a simple Markov process defined with

mp = DiscreteMarkovProcess[1, ( {
     {1/3, 1/3, 1/3, 0},
     {1/2, 1/4, 0, 1/4},
     {0, 0, 1, 0},
     {0, 0, 0, 1}
    } )];

How I change the initial state of this process, without defining an entirely new process. Is there a way to "set" the initial probabilities of mp to different values?

share|improve this question
    
Your question is unclear: the initial state is... a state, not a probability. Is that what you want to change, or do you mean you want to change the transition matrix without redefining it? If the latter, just make the matrix symbolic, and then enclose your cases in Block, with the symbols defined to the values you want. –  rasher May 10 at 22:17
1  
The first argument can be either a single state or a list of initial state probabilities. You can simply define mp as a function having the initial state or state vector as one of its arguments. –  Sjoerd C. de Vries May 10 at 22:46
    
@SjoerdC.deVries: That sounds like the answer (if in fact there's no particular way to change the initial state once it's been set. –  raxacoricofallapatorius May 11 at 2:27
    
@raxacoricofallapatorius: You can use the same technique I allude to for initial state, just define the state as a symbol, easy peasy. –  rasher May 11 at 4:48
    
@rasher: If you change the answer to match the question (about initial state, not the transition matrix), that will work. –  raxacoricofallapatorius May 12 at 16:44

2 Answers 2

up vote 3 down vote accepted

Resetting the first Part of mp, e.g., mp[[1]]=2 seems to work.

mp = DiscreteMarkovProcess[1, ({{1/3, 1/3, 1/3, 0}, {1/2, 1/4, 0, 1/4}, {0, 0, 1, 0},
    {0, 0,  0, 1}})];
Row[{MarkovProcessProperties[mp] /. Grid[x_, y__] :> 
            Grid[x[[Join[Range[4], Range[-8, -1]]]], y], 
    mp[[1]] = 2; MarkovProcessProperties[mp] /. Grid[x_, y__] :> 
            Grid[x[[Join[Range[4], Range[-8, -1]]]], y]},  Spacer[5]]

enter image description here

share|improve this answer

There's no feature of DiscreteMarkovProcess that supports this, but you can accomplish what you want using basic language features, for example:

mp = DiscreteMarkovProcess[state, ( {
     {1/3, 1/3, 1/3, 0},
     {1/2, 1/4, 0, 1/4},
     {0, 0, 1, 0},
     {0, 0, 0, 1}} )];

Block[{state=3}, <do stuff with MP>...]

Of course, you need to insure that whatever symbol you choose to use is not defined at the time of the DMP definition, otherwise that value will be used in the definition.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.