def bootStraps(dat, n=1):
 dat = numpy.asarray(dat)
 if (len(dat.shape) == 1):
  dat = numpy.array([dat])
 nTrials = dat.shape[1]
 resamples = numpy.zeros((dat.shape + (n,)), dat.dtype)
 rand = numpy.random.rand
 for stimulusN in range(dat.shape[0]):
  thisStim = dat[stimulusN, :]
  for sampleN in range(n):
   indices = numpy.floor((nTrials * rand(nTrials))).astype('i')
   resamples[stimulusN, :, sampleN] = numpy.take(thisStim, indices)
 return resamples

def bootStraps ( dat , n = 1 ) : dat = numpy . asarray ( dat ) if ( len ( dat . shape ) == 1 ) : dat = numpy . array ( [ dat ] ) nTrials = dat . shape [ 1 ] resamples = numpy . zeros ( ( dat . shape + ( n , ) ) , dat . dtype ) rand = numpy . random . rand for stimulusN in range ( dat . shape [ 0 ] ) : thisStim = dat [ stimulusN , : ] for sampleN in range ( n ) : indices = numpy . floor ( ( nTrials * rand ( nTrials ) ) ) . astype ( 'i' ) resamples [ stimulusN , : , sampleN ] = numpy . take ( thisStim , indices ) return resamples
create a list of n bootstrapped resamples of the data slow implementation usage: out = bootstraps where: dat an nxm or 1xn array n number of bootstrapped resamples to create out - dim[0]=conditions - dim[1]=trials - dim[2]=resamples .