def _calc_median_hist (self, hist_items, n_indiv):
        sum_count = 0
        mid_count = float(n_indiv) / 2

        if n_indiv == 1:
            return hist_items[0][0]
        else:
            for i in xrange(len(hist_items)):
                bin, count = hist_items[i]
                sum_count += count

                if sum_count == mid_count:
                    return bin
                elif sum_count > mid_count:
                    bin0, count0 = hist_items[i - 1]
                    return ((bin0 * count0) + (bin * count)) / (count0 + count)
calculate the median from a fitness histogram
dataset/ETHPy150Open ceteri/exelixi/src/uow.py/UnitOfWorkFactory._calc_median_hist