title: Implementing markov Chain Example - java
body: <p>There are plenty of Markov Chain examples for text simulations, however for a state change (for ex weather change based on probability over time) I couldn't find any examples. For ex, lets say</p>
  
  <pre><code>Sunny --&gt; Sunny = probability is 0.8
  Sunny --&gt; Rainy = probability is 0.2
  </code></pre>
  
  <p>what I am looking is a way to write an algorithm which will display the current weather till n no of steps.</p>
  
  <p>for e.g:  <code>f(3) =&gt; S,S,R</code></p>
  
  <p>I guess what I am really finding it difficult is how to put the randomness to the algorithm.</p>
  
  <p><a href="https://gist.github.com/veryphatic/3190969" rel="nofollow noreferrer">This</a> algorithm generate a sentence based on the probability of given words in a phrase, but I am unable to map it into my requirement.( I am not good in maths)</p>
  
  <p>And pls let me know how can I extend the algorithm, for ex 
  if the probability of a sunny day with high humidity is 0.3, the function should produce something like</p>
  
  <pre><code> f(4) -&gt; [S,Low Hu],[S, Low Hu],[R,High Hu] etc..
  </code></pre>
  
  <p><s>Please let me know whether this approach is good for my requirement.</s>
  pseudo code would be enough.</p>