def populationStability(vectors, numSamples=None):
 numVectors = len(vectors)
 if (numSamples is None):
  numSamples = (numVectors - 1)
  countOn = range((numVectors - 1))
 else:
  countOn = numpy.random.randint(0, (numVectors - 1), numSamples)
 sigmap = 0.0
 for i in countOn:
  match = checkMatch(vectors[i], vectors[(i + 1)], sparse=False)
  if (match[1] != 0):
   sigmap += (float(match[0]) / match[1])
 return (sigmap / numSamples)

def populationStability ( vectors , numSamples = None ) : numVectors = len ( vectors ) if ( numSamples is None ) : numSamples = ( numVectors - 1 ) countOn = range ( ( numVectors - 1 ) ) else : countOn = numpy . random . randint ( 0 , ( numVectors - 1 ) , numSamples ) sigmap = 0.0 for i in countOn : match = checkMatch ( vectors [ i ] , vectors [ ( i + 1 ) ] , sparse = False ) if ( match [ 1 ] != 0 ) : sigmap += ( float ( match [ 0 ] ) / match [ 1 ] ) return ( sigmap / numSamples )
returns the stability for the population averaged over multiple time steps parameters: vectors: the vectors for which the stability is calculated numsamples the number of time steps where stability is counted at each time step .