title: Using random generator with probability using matlab
body: <p>THe following code generates random numbers with a given probability of success:</p>
  
  <pre><code>         n=[randi([0 1],1,8) ones(1,8)];
           n= n(randperm(10));
  </code></pre>
  
  <p>If the above lines are repeated random (unpridictable) values will be generated:</p>
  
  <p>This is n for the first run:</p>
  
  <pre><code> n =     1     0     1     0     0     1     1     1     1     1
  </code></pre>
  
  <p>This is n for the second run:</p>
  
  <pre><code> n =     1     1     1     0     1     1     1     1     1     1
  </code></pre>
  
  <p>How can I make the generator picking the number of already selected as failure(0) with higher probability?</p>
  
  <p>That is the probability person 2, 3 and 4 in the second round has more probability of loosing. This does not mean that they have to fail.</p>
  
  <p>The entries 1 to 10 are 10 different user outputs. </p>
  
  <p>ok let us say always a max of 30% of entries will be 0. In every time the above is executed. However this is done randomly. So a max of any 3 of the 10 can be zero.</p>
  
  <p>I do not want the probability of success to change.Just to control which one is zero.</p>
  
  <p>To clarify further What I want: If 3 will be chosen "randomly" to be zero then let the previously chosen three have higher probability to be picked and not be picked.</p>