code: def knuth_bin_width(data, return_bins=False, disp=True):
      r"""Return the optimal histogram bin width using Knuth's rule [1]_
  
      Parameters
      ----------
      data : array-like, ndim=1
          observed (one-dimensional) data
      return_bins : bool (optional)
          if True, then return the bin edges
  
      Returns
      -------
      dx : float
          optimal bin width. Bins are measured starting at the first data point.
      bins : ndarray
          bin edges: returned if `return_bins` is True
  
      Notes
      -----
      The optimal number of bins is the value M which maximizes the function
  
      .. math::
          F(M|x,I) = n\log(M) + \log\Gamma(\frac{M}{2})
          - M\log\Gamma(\frac{1}{2})
          - \log\Gamma(\frac{2n+M}{2})
          + \sum_{k=1}^M \log\Gamma(n_k + \frac{1}{2})
  
      where :math:`\Gamma` is the Gamma function, :math:`n` is the number of
      data points, :math:`n_k` is the number of measurements in bin :math:`k`.
  
      References
      ----------
      .. [1] Knuth, K.H. "Optimal Data-Based Binning for Histograms".
             arXiv:0605197, 2006
  
      See Also
      --------
      KnuthF
      freedman_bin_width
      scotts_bin_width
      """
      return astropy_stats.knuth_bin_width(data, return_bins)
  
file_path: astroML/astroML/density_estimation/histtools.py
imports: import numpy
  from scipy.special import gammaln
  from astropy import stats
  from astroML.utils import deprecated
  from astroML.utils.exceptions import AstroMLDeprecationWarning
label_desc: Use image node_id 3 for calling a global function with example usage: knuth_bin_width(data, return_bins, disp) and returns: astropy_stats