code: def plot_transaction_rate_heterogeneity(
      model,
      suptitle="Heterogeneity in Transaction Rate",
      xlabel="Transaction Rate",
      ylabel="Density",
      suptitle_fontsize=14,
      **kwargs
  ):
      
      from matplotlib import pyplot as plt
  
      r, alpha = model._unload_params("r", "alpha")
      rate_mean = r / alpha
      rate_var = r / alpha ** 2
  
      rv = stats.gamma(r, scale=1 / alpha)
      lim = rv.ppf(0.99)
      x = np.linspace(0, lim, 100)
  
      fig, ax = plt.subplots(1)
      fig.suptitle("Heterogeneity in Transaction Rate", fontsize=suptitle_fontsize, fontweight="bold")
  
      ax.set_title("mean: {:.3f}, var: {:.3f}".format(rate_mean, rate_var))
      ax.set_xlabel(xlabel)
      ax.set_ylabel(ylabel)
  
      fig.tight_layout(rect=[0, 0.03, 1, 0.95])
      plt.plot(x, rv.pdf(x), **kwargs)
      return ax
docs: Plot the estimated gamma distribution of lambda (customers' propensities to purchase).
  
      Parameters
      ----------
      model: lifetimes model
          A fitted lifetimes model, for now only for BG/NBD
      suptitle: str, optional
          Figure suptitle
      xlabel: str, optional
          Figure xlabel
      ylabel: str, optional
          Figure ylabel
      kwargs
          Passed into the matplotlib.pyplot.plot command.
  
      Returns
      -------
      axes: matplotlib.AxesSubplot