title: Looping a function with irregular index increase
body: <p>I have my function:  </p>
  
  <pre><code>import numpy as np
  
  def monte_carlo1(N):
      x = np.random.random (size = N)
      y = np.random.random (size = N)
  
      dist = np.sqrt(x ** 2 + y ** 2)
      hit = 0
      miss = 0
  
  
      for z in dist:
          if z &lt;=1:
              hit += 1
          else:
              miss +=1
  
      hit_ratio = hit / N
  
      return hit_ratio
  </code></pre>
  
  <p>What i want to do is run this function 100 times each for 10 different values of N, collecting the data into arrays.</p>
  
  <p>For example, a couple of the data collections could be generated by:</p>
  
  <pre><code>data1 = np.array([monte_carlo1(10) for i in range(100)])
  data2 = np.array([monte_carlo1(50) for i in range(100)])
  data3 = np.array([monte_carlo1(100) for i in range(100)])  
  </code></pre>
  
  <p>But it would be better if I could create a while loop which can iterate 10 times to produce 10 arrays of data instead of having 10 variables data1...data10.</p>
  
  <p>However, I want to be able to increase the values of N inside monte_carlo(N) by irregular amounts, so in my loop i cant just add a fixed value to N each iteration.</p>
  
  <p>WOuld someone suggest how I might build a loop like this?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:</p>
  
  <pre><code>N_vals = [10, 50, 100, 250, 500, 1000, 3000, 5000, 7500, 10000]
  
  
  def data_mc():
      for n in N_vals:
          data = np.array([monte_carlo1(n) for i in range(10)])
      return data
  </code></pre>
  
  <p>I've set up the function like this but the output of the function is just one array, which suggests im doing something wrong and the N_values isnt being cycled through</p>