title: Stratified Sampling in Python without scikit-learn
body: <p>I have a vector which contains 10 values of sample 1 and 25 values of sample 2.</p>
  <pre><code>Fact = np.array((2,2,2,2,1,2,1,1,2,2,2,1,2,2,2,1,2,2,2,1,2,2,1,1,2,1,2,2,2,2,2,2,1,2,2))
  </code></pre>
  <p>I want to create a stratified output vector where :</p>
  <p>sample 1 is divided in 80% : 8 values of 1 and 20% : 2 values of 0.</p>
  <p>sample 2 is divided in 80% : 20 values of 1 and 20% : 5 values of 0.</p>
  <p>The expected output will be :</p>
  <pre><code>Output = np.array((0,1,1,1,0,1,1,1,1,0,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1))
  </code></pre>
  <p>How can I automate this ? I can’t use the sampling function from scikit-learn because it is not for a machine learning experience.</p>