lib/mini_histogram.rb
# Weird name, right? There are multiple ways to
# calculate the number of "bins" a histogram should have, one
# of the most common is the "sturges" method
#
# Here are some alternatives from numpy:
# https://github.com/numpy/numpy/blob/d9b1e32cb8ef90d6b4a47853241db2a28146a57d/numpy/lib/histograms.py#L489-L521
Weird name, right. There are multiple ways to
calculate the number of "bins" a histogram should have, one
of the most common is the "sturges" method


Weird name right . There are multiple ways to calculate the number of " bins " a histogram should have one of the most common is the " sturges " method
def sturges
    len = array.length
    return 1.0 if len == 0
    return Math.log2(len).ceil + 1
  end
def sturges len = array . length return 1.0 if len == 0 return Math . log2 ( len ) . ceil + 1 end
Weird name, right?
Weird name right?
# return (long)(ceil(Math.log2(n)) + 1);