title: Solving probability problems with MATLAB
body: <p>How can I simulate this question using MATLAB?</p>
  <blockquote>
  <p>Out of 100 apples, 10 are rotten. We randomly choose 5 apples without
  replacement. What is the probability that there is at least one
  rotten?</p>
  </blockquote>
  <p>The Expected Answer</p>
  <blockquote>
  <p>0.4162476</p>
  </blockquote>
  <p>My Attempt:</p>
  <pre class="lang-matlab prettyprint-override"><code>r=0
  for i=1:10000
      for c=1:5
          a = randi(1,100);
          if a &lt; 11
              r=r+1;
          end
      end
  end
  r/10000
  </code></pre>
  <p>but it didn't work, so what would be a better way of doing it?</p>