made sample_discrete_from_log_2d_destructive more numerically robust
fixed broken sample_discrete_from_log_2d
broke out parallel cost function