def knuth_bin_width(data, return_bins=False, quiet=True):
 from scipy import optimize
 knuthF = _KnuthF(data)
 (dx0, bins0) = freedman_bin_width(data, True)
 M = optimize.fmin(knuthF, len(bins0), disp=(not quiet))[0]
 bins = knuthF.bins(M)
 dx = (bins[1] - bins[0])
 if return_bins:
  return (dx, bins)
 else:
  return dx

def knuth_bin_width ( data , return_bins = False , quiet = True ) : from scipy import optimize knuthF = _KnuthF ( data ) ( dx0 , bins0 ) = freedman_bin_width ( data , True ) M = optimize . fmin ( knuthF , len ( bins0 ) , disp = ( not quiet ) ) [ 0 ] bins = knuthF . bins ( M ) dx = ( bins [ 1 ] - bins [ 0 ] ) if return_bins : return ( dx , bins ) else : return dx
return the optimal histogram bin width using knuths rule .