title: How to let Boost::random and Matlab produce the same random numbers
body: <p>To check my C++ code, I would like to be able to let Boost::Random and Matlab produce the same random numbers.</p>
  
  <p>So for Boost I use the code:</p>
  
  <pre><code>boost::mt19937 var(static_cast&lt;unsigned&gt; (std::time(0)));
  boost::uniform_int&lt;&gt; dist(1, 6);
  boost::variate_generator&lt;boost::mt19937&amp;, boost::uniform_int&lt;&gt; &gt; die(var, dist);
  die.engine().seed(0);     
  for(int i = 0; i &lt; 10; ++i) {
      std::cout &lt;&lt; die() &lt;&lt; " ";
  }      
  std::cout    &lt;&lt; std::endl;
  </code></pre>
  
  <p>Which produces (every run of the program):<br>
  <code>4 4 5 6 4 6 4 6 3 4</code></p>
  
  <p>And for matlab I use:</p>
  
  <pre><code>RandStream.setDefaultStream(RandStream('mt19937ar','seed',0));
  randi(6,1,10)
  </code></pre>
  
  <p>Which produces (every run of the program):<br>
  <code>5     6     1     6     4     1     2     4     6     6</code></p>
  
  <p>Which is bizarre, since both use the same algorithm, and same seed.
  What do I miss?</p>
  
  <p>It seems that Python (using numpy) and Matlab seems comparable, in the random uniform numbers:
  Matlab</p>
  
  <p>RandStream.setDefaultStream(RandStream('mt19937ar','seed',203));rand(1,10)</p>
  
  <p><code>0.8479    0.1889    0.4506    0.6253    0.9697    0.2078    0.5944    0.9115    0.2457    0.7743</code></p>
  
  <p>Python: 
  random.seed(203);random.random(10)</p>
  
  <p><code>array([ 0.84790006,  0.18893843,  0.45060688,  0.62534723,  0.96974765,
          0.20780668,  0.59444858,  0.91145688,  0.24568615,  0.77430378])</code></p>
  
  <p>C++Boost</p>
  
  <p><code>0.8479 0.667228 0.188938 0.715892 0.450607 0.0790326 0.625347 0.972369 0.969748 0.858771</code></p>
  
  <p>Which is identical to ever other Python and Matlab value...</p>