title: Python numpy.random.binomial() function
body: <p>I'm trying to use the np.random.binomial() function to simulate a number of coin flips with the following given parameters:</p>
  <ul>
  <li>Number of coins = 10</li>
  <li>Number of flips per coin = 1</li>
  <li>Probability of having a Head P(H) = 0.5 &quot;i.e Fair Coin&quot;</li>
  <li>Number of trials = 1000,000</li>
  </ul>
  <p>I've used the following code to get the result:</p>
  <p>[CODE]</p>
  <pre><code>%%time    
  tests = np.random.binomial(n=1, p=0.5, size=(int(1e6), 10))
  test_sums = tests.sum(axis=1) # axis=1 to sum each row
  (test_sums == 4).mean()
  </code></pre>
  <p>[OUTPUT]</p>
  <pre><code>(Wall time: 248 ms)
  0.204992
  </code></pre>
  <p>One of my teammates recommended the following snippet which uses less code and seems more efficient:</p>
  <p>[CODE]</p>
  <pre><code>%%time    
  tests = np.random.binomial(n=10, p=0.5, size=int(1e6))
  (tests == 4).mean()
  </code></pre>
  <p>[OUTPUT]</p>
  <pre><code>Wall time: 68.9 ms
  0.2048
  </code></pre>
  <p>When can I use either of the following:</p>
  <pre><code>tests = np.random.binomial(n=1, p=0.5, size=(int(1e6), 10))
  tests = np.random.binomial(n=10, p=0.5, size=int(1e6))
  </code></pre>
  <p>Could you please advise what is the difference between the two cases? Knowing that, the result is, we can say, the same.</p>