def unintegrate(x, levels):
 levels = list(levels)[:]
 if (len(levels) > 1):
  x0 = levels.pop((-1))
  return unintegrate(np.cumsum(np.r_[(x0, x)]), levels)
 x0 = levels[0]
 return np.cumsum(np.r_[(x0, x)])

def unintegrate ( x , levels ) : levels = list ( levels ) [ : ] if ( len ( levels ) > 1 ) : x0 = levels . pop ( ( - 1 ) ) return unintegrate ( np . cumsum ( np . r_ [ ( x0 , x ) ] ) , levels ) x0 = levels [ 0 ] return np . cumsum ( np . r_ [ ( x0 , x ) ] )
after taking n-differences of a series .