def _log_wishart_const(num_features, nws_dof, nws_scale_matrix): """Compute `log_wishart_const_init` """ if nws_scale_matrix.ndim == 2: ld = logdet(nws_scale_matrix) else: ld = [logdet(nws_scale_matrix[k, :, :]) for k in range(nws_scale_matrix.shape[0])] log_wishart_const = ( (nws_dof / 2) * ld - (nws_dof * num_features / 2) * log(2) - mvt_gamma_ln(num_features, nws_dof / 2) ) return log_wishart_const
def _log_wishart_const(num_features, nws_dof, nws_scale_matrix): """Compute `log_wishart_const_init` """ log_wishart_const = ((nws_dof / 2) * logdet(nws_scale_matrix) - (nws_dof * num_features / 2) * log(2) - mvt_gamma_ln(num_features, nws_dof / 2)) return log_wishart_const
def _update_log_det_precision(num_features, num_comp, posterior_nws_dof, posterior_nws_scale_matrix): """ Update `log_det_precision` """ update = lambda k: (np.sum(psi((posterior_nws_dof[k] + 1 - range(1, num_features + 1)) / 2)) + num_features * log(2) - logdet(posterior_nws_scale_matrix[k, :, :])) log_det_precision = [update(k) for k in range(num_comp)] return log_det_precision