def compute_empirical_cdf(bin_edges, hist):
    """
    Compute an empirical cumulative distribution function from the given
    histogram.

    Parameters
    ----------
    bin_edges: array_like
        Coordinates of left edges of the histogram bins.
    hist: array_like
        Histogram counts for each bin.

    Returns
    -------
    out: ndarray
        CDF values corresponding to the bin edges.

    """
    cdf = []
    xs = 0.0

    for x, h in zip(zip(bin_edges[:-1], bin_edges[1:]), hist):
        cdf.append(xs)
        xs += (x[1] - x[0]) * h

    cdf.append(xs)
    cdf = np.array(cdf) / xs

    return cdf
Compute an empirical cumulative distribution function from the given
histogram.

Parameters
----------
bin_edges: array_like
Coordinates of left edges of the histogram bins.
hist: array_like
Histogram counts for each bin.

Returns
-------
out: ndarray
CDF values corresponding to the bin edges.
pysteps/postprocessing/probmatching.py