<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hello fellow Scilab Users,<br><br>I am using the grand() function to generate a state sequence for a 2-state Markov chain.<br>It works fine to generate the sequence, but I don't quite understand how the initial state parameter 'x0' works. Here is the code I use:<br><br>//-------------------<br><font style="" face="Courier New">N=50;</font><font style="" face="Courier New"> //length of sequence<br></font><font style="" face="Courier New">P=[0.6 0.4;0.1 0.9];</font><font style="" face="Courier New"> //state transition matrix<br></font><font style="" face="Courier New">q=grand(N,'markov',P,[1]);</font><font style="" face="Courier New"> //initial state is '1'<br></font><font style="" face="Courier New">q=-(q*2.0-3.0);</font><font style="" face="Courier New"> //normalize to -1:+1 range<br></font><font style="" face="Courier New"><br>clf();</font><font style="" face="Courier New"><br></font><font style="" face="Courier New"></font><font style="" face="Courier New">plot2d3([1:N],[q],[0],rect=[0,-1.5,N,1.5],leg='2-state Markov chain');</font><br>//------------------<br><br>If you run this piece of code a few times, sometimes it will start with state '1', but not always.<br><br>From the help page I understand that:<br><br>- if I want the chain to start in state '1', then I just have to make 'x0 = [1]', as in the code above;<br><br>- if I want the state sequence to start from state '2', then I should do 'x0=[2]'.<br><br>- if I want to get paths starting from both states I would make x0=[1 2], and each column of q (the output) would represent a path starting at the corresponding state.<br><br>However, if I make x0=[1] or x0=[2], I get realizations starting from any of the states (sometimes state 1 and sometimes state 2) and that does not make much sense to me, because then, what are the limiting-state probabilities that the function is using to choose the initial state?<br>According to what is explained in the grand() help page, if I make, for example, x0=[1], shouldn't the sequence 'always' start in state 1?<br><br>I appreciate any help and clarifications on the behaviour of this function.<br><br>Best regards to all,<br><br>Dan<br> <br /><hr />Hotmail: Free, trusted and rich email service. <a href='https://signup.live.com/signup.aspx?id=60969' target='_new'>Get it now.</a></body>
</html>