title: Fisher Yates algorithm gives back same order of numbers in parallel started programs when seeded over the system time
body: <p>I start several C / C++ programs in parallel, which rely on random numbers. Fairly new to this topic, I heard that the seed should be done over the time. </p>
  
  <p>Furthermore, I use the Fisher Yates Algorithm to get a list with unique random shuffled values. However, starting the program twice in parallel gives back the same results for both lists. </p>
  
  <p>How can I fix this? Can I use a different, but still relient seed?</p>
  
  <p>My simple test code for this looks like this:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  #include &lt;time.h&gt;
  static int rand_int(int n) {
  
          int limit = RAND_MAX - RAND_MAX % n;
          int rnd;
  
          do {
                  rnd = rand();
          }
          while (rnd &gt;= limit);
          return rnd % n;
  }
  
  
  void shuffle(int *array, int n) {
  
          int i, j, tmp;
          for (i = n - 1; i &gt; 0; i--) {
                  j = rand_int(i + 1);
                  tmp = array[j];
                  array[j] = array[i];
                  array[i] = tmp;
          }
  }
  
  
  int main(int argc,char* argv[]){
  
          srand(time(NULL));
          int x = 100;
          int randvals[100];
          for(int i =0; i &lt; x;i++)
                  randvals[i] = i;
  
          shuffle(randvals,x);
          for(int i=0;i &lt; x;i++)
                  printf("%d %d \n",i,randvals[i]);
  
  }
  </code></pre>
  
  <p>I used the implementation for the fisher yates algorithm from here:</p>
  
  <p><a href="http://www.sanfoundry.com/c-program-implement-fisher-yates-algorithm-array-shuffling/" rel="nofollow noreferrer">http://www.sanfoundry.com/c-program-implement-fisher-yates-algorithm-array-shuffling/</a></p>
  
  <p>I started the programs in parallel like this:</p>
  
  <pre><code>./randomprogram &gt;&gt; a.txt &amp; ./randomprogram &gt;&gt; b.txt
  </code></pre>
  
  <p>and then compared both text files, which had the same content. </p>
  
  <p>The end application is for data augmentation in the deep learning field. The machine runs Ubuntu 16.04 with C++11.</p>