def __gamma_function_errors(self, p, mode, fit_end, offset, channel):
        start  = self.histograms[channel][0]
        width  = self.histograms[channel][1]
        values = self.histograms[channel][2]
        k = p[0]
        bm = self.backscatter_model[channel]
        if (bm == RadarHistogram.BACKSCATTER_MODEL_GAMMA and k <= 1.0):
            return [float('inf')] * len(values)
        if (bm == RadarHistogram.BACKSCATTER_MODEL_GAUSSIAN and k <= 0.0):
            return [float('inf')] * len(values)
        error = 0.0
        last_cdf = 0.0
        errors = numpy.zeros(len(values))
        mid = int((mode - start) / width)
        cumulative = sum(values[:mid]) + values[mid] / 2
        scale = cumulative / self.__cdf((mode, k, offset), mode, bm)
        for i in range(len(values)):
            if start + i * width - offset > fit_end:
                break
            cdf = scale * self.__cdf((mode, k, offset), start + i * width, bm)
            errors[i] = (cdf - last_cdf) - values[i]
            last_cdf = cdf
        return errors
dataset/ETHPy150Open nasa/CrisisMappingToolkit/cmt/radar/histogram.py/RadarHistogram.__gamma_function_errors/original