code: def confidence_interval_min_width(mu, post, alpha=0.9):
      '''
      Returns the minimal-width confidence interval [mu_low, mu_high] of
      confidence level alpha for a posterior distribution post on the parameter mu.
      '''
      if not 0 < alpha < 1:
          raise ValueError("Confidence level must be in (0,1).")
  
      # choose a step size for the sliding confidence window
      alpha_step = 0.01
  
      # initialize the lower and upper limits
      mu_low = numpy.min(mu)
      mu_high = numpy.max(mu)
  
      # find the smallest window (by delta-mu) stepping by dalpha
      for ai in numpy.arange(0, 1 - alpha, alpha_step):
          ml = compute_lower_limit(mu, post, 1 - ai)
          mh = compute_upper_limit(mu, post, alpha + ai)
          if mh - ml < mu_high - mu_low:
              mu_low = ml
              mu_high = mh
  
      return mu_low, mu_higf confidence_interval_min_width(mu, post, alpha=0.9):
      '''
      Returns the minimal-width confidence interval [mu_low, mu_high] of
      confidence level alpha for a posterior distribution post on the parameter mu.
      '''
      if not 0 < alpha < 1:
          raise ValueError("Confidence level must be in (0,1).")
  
      # choose a step size for the sliding confidence window
      alpha_step = 0.01
  
      # initialize the lower and upper limits
      mu_low = numpy.min(mu)
      mu_high = numpy.max(mu)
  
      # find the smallest window (by delta-mu) stepping by dalpha
      for ai in numpy.arange(0, 1 - alpha, alpha_step):
          ml = compute_lower_limit(mu, post, 1 - ai)
          mh = compute_upper_limit(mu, post, alpha + ai)
          if mh - ml < mu_high - mu_low:
              mu_low = ml
              mu_high = mh
  
      return mu_low, mu_high
docs: Returns the minimal-width confidence interval [mu_low, mu_high] of
      confidence level alpha for a posterior distribution post on the parameter mu.