#NEWLINE# def sum_outer_product_balanced( x , n_groups ) : #NEWLINE# #INDENT# 'sum outerproduct dot(x_i, x_i.T) over individuals\n\n    where x_i is (nobs_i, 1), and result is (nobs_i, nobs_i)\n\n    reshape-dot version, for x.ndim=1 only\n\n    ' #NEWLINE# xrs = x . reshape ( ( - 1 ) , x , order = 'F' ) #NEWLINE# return np . dot ( xrs , xrs . T )