r'''
Compute cumulative histogram.
See `numpy.histrogram <https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html>`_

:extra options:

  **return_edges** ([``True``] | [``False``])
    Return the bin edges if set to ``True``, return their midpoints otherwise.

  **normalize** ([``False``] | ``True``)
    Normalize such that the final probability is one. In this case the function returns the (binned)
    cumulative probability density.

def histogram_cumulative(data,**kwargs):
  r'''
Compute cumulative histogram.
See `numpy.histrogram <https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html>`_

:extra options:

  **return_edges** ([``True``] | [``False``])
    Return the bin edges if set to ``True``, return their midpoints otherwise.

  **normalize** ([``False``] | ``True``)
    Normalize such that the final probability is one. In this case the function returns the (binned)
    cumulative probability density.
  '''

  return_edges = kwargs.pop('return_edges', True)

  norm = kwargs.pop('normalize', False)

  P, edges = np.histogram(data, **kwargs)

  P = np.cumsum(P)

  if norm: P = P/P[-1]

  if not return_edges: edges = np.diff(edges) / 2. + edges[:-1]

  return P, edges