code: def posterior_step(logposts, dim):
      
      if logposts.ndim > 1:
          raise ValueError("logposts must be a 1D array")
      criteria = dim/2.
      dp = numpy.diff(logposts)
      indices = numpy.where(dp >= criteria)[0]
      if indices.size > 0:
          idx = indices[-1] + 1
      else:
          idx = 0
      return idx
docs: Finds the last time a chain made a jump > dim/2.
  
      Parameters
      ----------
      logposts : array
          1D array of values that are proportional to the log posterior values.
      dim : int
          The dimension of the parameter space.
  
      Returns
      -------
      int
          The index of the last time the logpost made a jump > dim/2. If that
          never happened, returns 0.