How many bins should a histogram have? Too few hides structure, too many shows noise. Implement the classic rules for a 1-D array of n values:
sturges_bins(x): ceil(log2(n)) + 1freedman_diaconis_width(x): 2 * IQR / n^(1/3), using np.percentile for the IQRfd_bins(x): ceil((max - min) / width), or 1 if the width is 0histogram(x, bins): return (counts, edges) for bins equal-width bins from min to max, where each bin is half-open [a, b) except the last, which includes the maximum. Don't use np.histogram (you can compare against it).