def discrete_sequence(n, distribution=None, cdistribution=None):
 import bisect
 if (cdistribution is not None):
  cdf = cdistribution
 elif (distribution is not None):
  cdf = cumulative_distribution(distribution)
 else:
  raise nx.NetworkXError('discrete_sequence: distribution or cdistribution missing')
 inputseq = [random.random() for i in range(n)]
 seq = [(bisect.bisect_left(cdf, s) - 1) for s in inputseq]
 return seq

def discrete_sequence ( n , distribution = None , cdistribution = None ) : import bisect if ( cdistribution is not None ) : cdf = cdistribution elif ( distribution is not None ) : cdf = cumulative_distribution ( distribution ) else : raise nx . NetworkXError ( 'discrete_sequence: distribution or cdistribution missing' ) inputseq = [ random . random ( ) for i in range ( n ) ] seq = [ ( bisect . bisect_left ( cdf , s ) - 1 ) for s in inputseq ] return seq
return sample sequence of length n from a given discrete distribution or discrete cumulative distribution .