def asquare(cdfvals, axis=0):
 ndim = len(cdfvals.shape)
 nobs = cdfvals.shape[axis]
 slice_reverse = ([slice(None)] * ndim)
 islice = ([None] * ndim)
 islice[axis] = slice(None)
 slice_reverse[axis] = slice(None, None, (-1))
 asqu = ((- ((((2.0 * np.arange(1.0, (nobs + 1))[islice]) - 1) * (np.log(cdfvals) + np.log((1 - cdfvals[slice_reverse])))) / nobs).sum(axis)) - nobs)
 return asqu

def asquare ( cdfvals , axis = 0 ) : ndim = len ( cdfvals . shape ) nobs = cdfvals . shape [ axis ] slice_reverse = ( [ slice ( None ) ] * ndim ) islice = ( [ None ] * ndim ) islice [ axis ] = slice ( None ) slice_reverse [ axis ] = slice ( None , None , ( - 1 ) ) asqu = ( ( - ( ( ( ( 2.0 * np . arange ( 1.0 , ( nobs + 1 ) ) [ islice ] ) - 1 ) * ( np . log ( cdfvals ) + np . log ( ( 1 - cdfvals [ slice_reverse ] ) ) ) ) / nobs ) . sum ( axis ) ) - nobs ) return asqu
vectorized anderson darling a^2 .