title: Randomly split users into two groups in the percentage of 80:20
body: <p>I have a list of ids called users and want to split them randomly into two groups by the percentage of 80:20. </p>
  
  <p>For example i have a list of 100 users ids and randomly put 80 users into group1 and remaining 20 into group2</p>
  
  <pre><code> def getLevelForIncrementality(Object[] args) {
     try {
       if (args.length &gt;= 1 &amp;&amp; args[0]!="") {
          String seed = args[0] + "Testing";
          int rnd = Math.abs(seed.hashCode() % 100);
          return (rnd &gt;= 80 ? 2 : 1);
       }
    } catch (Exception e) { }
   return 3;
  }
  </code></pre>
  
  <p>I have tried from the above groovy code which gives me in the ratio of 82:18.</p>
  
  <p>Can someone give me some insights or suggestions or alogrithms which can solve the above problem for millions of user ids.</p>