title: Random boolean with weight or bias
body: <p>I need to generate some random booleans.  However I need to be able to specify the probability of returning <code>true</code>.  As a results doing:</p>
  <pre><code>private Random random = new Random();
  random.nextBoolean();
  </code></pre>
  <p>will not work.</p>
  <p>One possible solution would be:</p>
  <pre><code>private Random random = new Random()
  
  public boolean getRandomBoolean(float p){
      return random.nextFloat() &lt; p;
  }
  </code></pre>
  <p>I was wondering if there is a better or more natural way of doing this.</p>
  <p>EDIT:
  I guess I am asking whether there is a library class that provides a nextBoolean(float probability) method.</p>