code: def discrete_sequence(
      n, distribution=None, cdistribution=None, seed=None
  ):
      """
      Return sample sequence of length n from a given discrete distribution
      or discrete cumulative distribution.
  
      One of the following must be specified.
  
      distribution = histogram of values, will be normalized
  
      cdistribution = normalized discrete cumulative distribution
  
      """
      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"
          )
  
      # get a uniform random number
      inputseq = [seed.random() for i in range(n)]
  
      # choose from CDF
      seq = [bisect.bisect_left(cdf, s) - 1 for s in inputseq]
      return seq
  
file_path: networkx/networkx/utils/random_sequence.py
imports: import networkx
  from networkx.utils import py_random_state
label_desc: Use image node_id 4 for calling a global function with example usage: discrete_sequence(n, distribution, cdistribution, seed) and returns: seq