code: def multinomial_resample(weights):
      
      cumulative_sum = np.cumsum(weights)
      cumulative_sum[-1] = 1.  # avoid round-off errors: ensures sum is exactly one
      return np.searchsorted(cumulative_sum, random(len(weights)))
docs: This is the naive form of roulette sampling where we compute the
      cumulative sum of the weights and then use binary search to select the
      resampled point based on a uniformly distributed random number. Run time
      is O(n log n). You do not want to use this algorithm in practice; for some
      reason it is popular in blogs and online courses so I included it for
      reference.
  
     Parameters
     ----------
  
      weights : list-like of float
          list of weights as floats
  
      Returns
      -------
  
      indexes : ndarray of ints
          array of indexes into the weights defining the resample. i.e. the
          index of the zeroth resample is indexes[0], etc.