> and the second restores it after squaring.

Аfter squaring and *cumsum*. No restoring: cumsum is different, when you start calculate it from first or last element. Cumsum have not parameter for calculation from last element of array, so I revert input array on moment of cumsum calculation.

    >>> norm_histo = np.arange(0.5, step=0.1)
    >>> P1_sq = np.cumsum(norm_histo ** 2)
    >>> P2_sq = np.cumsum(norm_histo[::-1] ** 2)[::-1]
    >>> norm_histo
    array([ 0. ,  0.1,  0.2,  0.3,  0.4])
    >>> P1_sq
    array([ 0.  ,  0.01,  0.05,  0.14,  0.3 ])
    >>> P2_sq
    array([ 0.3 ,  0.3 ,  0.29,  0.25,  0.16])