def _expectation(X, centers, weights, concentrations, posterior_type="<STR_LIT>"):
n_examples, n_features = np.shape(X)<EOL>n_clusters, _ = centers.shape<EOL>if n_features <= <NUM_LIT:50>:  <EOL><INDENT>vmf_f = _vmf_log<EOL><DEDENT>else:<EOL><INDENT>vmf_f = _vmf_log_asymptotic<EOL><DEDENT>f_log = np.zeros((n_clusters, n_examples))<EOL>for cc in range(n_clusters):<EOL><INDENT>f_log[cc, :] = vmf_f(X, concentrations[cc], centers[cc, :])<EOL><DEDENT>posterior = np.zeros((n_clusters, n_examples))<EOL>if posterior_type == "<STR_LIT>":<EOL><INDENT>weights_log = np.log(weights)<EOL>posterior = np.tile(weights_log.T, (n_examples, <NUM_LIT:1>)).T + f_log<EOL>for ee in range(n_examples):<EOL><INDENT>posterior[:, ee] = np.exp(posterior[:, ee] - logsumexp(posterior[:, ee]))<EOL><DEDENT><DEDENT>elif posterior_type == "<STR_LIT>":<EOL><INDENT>weights_log = np.log(weights)<EOL>weighted_f_log = np.tile(weights_log.T, (n_examples, <NUM_LIT:1>)).T + f_log<EOL>for ee in range(n_examples):<EOL><INDENT>posterior[np.argmax(weighted_f_log[:, ee]), ee] = <NUM_LIT:1.0><EOL><DEDENT><DEDENT>return posterior<EOL>
Compute the log-likelihood of each datapoint being in each cluster.

    Parameters
    ----------
    centers (mu) : array, [n_centers x n_features]
    weights (alpha) : array, [n_centers, ] (alpha)
    concentrations (kappa) : array, [n_centers, ]

    Returns
    ----------
    posterior : array, [n_centers, n_examples]