def AreaUnderCurve(x, y):
 if (x.shape[0] != y.shape[0]):
  raise ValueError(('x and y should have the same shape to compute area under curve, but x.shape = %s and y.shape = %s.' % (x.shape, y.shape)))
 if (x.shape[0] < 2):
  raise ValueError(('At least 2 points are needed to compute area under curve, but x.shape = %s' % x.shape))
 order = np.argsort(x)
 x = x[order]
 y = y[order]
 h = np.diff(x)
 area = (np.sum((h * (y[1:] + y[:(-1)]))) / 2.0)
 return area

def AreaUnderCurve ( x , y ) : if ( x . shape [ 0 ] != y . shape [ 0 ] ) : raise ValueError ( ( 'x and y should have the same shape to compute area under curve, but x.shape = %s and y.shape = %s.' % ( x . shape , y . shape ) ) ) if ( x . shape [ 0 ] < 2 ) : raise ValueError ( ( 'At least 2 points are needed to compute area under curve, but x.shape = %s' % x . shape ) ) order = np . argsort ( x ) x = x [ order ] y = y [ order ] h = np . diff ( x ) area = ( np . sum ( ( h * ( y [ 1 : ] + y [ : ( - 1 ) ] ) ) ) / 2.0 ) return area
compute area under the curve using the trapezoidal rule parameters x : array .