generalize dist-Denergy to include partial derivs wrt dist params