I'm an admittedly pretty basic Python programmer, trying to learn as I encounter problems implementing various research problems. And I've hit one of those problems - particularly, how to handle loops where I'm returning a bunch of data, rather than the usual "out comes a single number" examples where you just add the result of the loop to everything previous.

Here's a Gist of the unlooped script I'm trying to run: https://gist.github.com/1390355

The really salient point is the end of the model_solve function:

def model_solve(t):
    # lots of variables set
    params = np.zeroes((n_steps,n_params)
    params[:,0] = beta
    params[:,1] = gamma
    timer = np.arange(n_steps).reshape(n_steps,1)
    SIR = spi.odeint(eq_system, startPop, t_interval)
    output = np.hstack((timer,SIR,params))
    return output

That returns the results of the ODE integration bit (spi.odeint) along with a simple "What time step are we on?" timer and essentially two columns of the value of two random variables repeated many, many times in the form of 4950 row and 7 column NumPy array.

The goal however is to run a Monte Carlo analysis of the two parameters (beta and gamma) which have random values. Essentially, I want to make a function that loops somewhat like so:

def loop_function(runs):
  for i in range(runs):
    model_solve(100)
    # output of those model_solves collected here
  # return collected output

That collected output would then be written to a file. Normally, I'd just have each model_solve function write its results to a file, but this code is going to be run on PiCloud or another platform where I don't necessarily have the ability to write a file until the results are returned to the local machine. Instead, I'm trying to get a return of a huge NumPy arra

Edit
Report