示例#1
0
    def reverse_cumulative(self, maximum=1.0, bin_edge="l"):
        """Cumulative from the right: number of values greater than bin value.

        Use `maximum=None` to get the raw counts.
        """
        cumul_hist = []
        total = 0.0
        hist = self(bin_edge)
        for k in reversed(sorted(hist.keys())):
            total += hist(k)
            cumul_hist.insert(0, total)

        cumul_hist = np.array(cumul_hist)
        if total == 0:
            return 0
        if maximum is not None:
            cumul_hist *= maximum / total

        xvals = self.xvals(bin_edge)
        return LookupFunction(xvals, cumul_hist)
示例#2
0
    def cumulative(self, maximum=1.0, bin_edge="r"):
        """Cumulative from the left: number of values less than bin value.

        Use `maximum=None` to get the raw counts.
        """
        cumul_hist = []
        total = 0.0
        hist = self(bin_edge)
        for k in sorted(hist.keys()):
            total += hist(k)
            cumul_hist.append(total)

        cumul_hist = np.array(cumul_hist)
        if total == 0:
            return 0
        if maximum is not None:
            cumul_hist *= maximum / total

        xvals = self.xvals(bin_edge)
        return LookupFunction(xvals, cumul_hist)
示例#3
0
 def __call__(self, bin_edge="m"):
     """Return copy of histogram if it has already been built"""
     hist = self.histogram()
     vals = self.xvals(bin_edge)
     return LookupFunction(vals, hist)