def approx_error(a_orig, w_approx):
 assert all(((v >= 0) for v in a_orig))
 assert is_weight(w_approx)
 assert (len(a_orig) == len(w_approx))
 w_orig = (np.array(a_orig, dtype=float) / sum(a_orig))
 return float(max((abs((v1 - v2)) for (v1, v2) in zip(w_orig, w_approx))))

def approx_error ( a_orig , w_approx ) : assert all ( ( ( v >= 0 ) for v in a_orig ) ) assert is_weight ( w_approx ) assert ( len ( a_orig ) == len ( w_approx ) ) w_orig = ( np . array ( a_orig , dtype = float ) / sum ( a_orig ) ) return float ( max ( ( abs ( ( v1 - v2 ) ) for ( v1 , v2 ) in zip ( w_orig , w_approx ) ) ) )
return the :math:ell_infty norm error from approximating the vector a_orig/sum with the weight vector w_approx .