def conditional_psi(self, x, k):
        """
        Compute the conditional distribution over psi given observation x and omega
        Using the notation from
        :param x:
        :return:
        """
        if x.ndim == 1:
            xx = x[None,:]
        else:
            xx = x

        Ck = xx[:,k].sum()
        N = xx.sum()

        notk = np.ones(self.K, dtype=np.bool)
        notk[k] = False

        # Compute zeta = log(\sum_{j \neq k} e^{\psi_j})
        zetak = logsumexp(self.psi[notk])

        # Compute rho
        self.rho[k] = self.psi[k] - zetak

        # Get the marginal distribution over rho under the prior
        muk_marg = self.mu[k] \
                   - 1./self.Lambda[k,k] * self.Lambda[k,notk].\
            dot(self.psi[notk] - self.mu[notk])
        sigmak_marg = 1./self.Lambda[k,k]

        # Compute the conditional posterior given psi[notk] and omega
        omegak = self.omega[k]
        sigmak_cond = 1./(omegak + 1./sigmak_marg)

        # kappa is the mean dot precision, i.e. the sufficient statistic of a Gaussian
        # therefore we can sum over datapoints
        kappa = (Ck - N/2.0).sum()
        muk_cond = sigmak_cond * (kappa + muk_marg / sigmak_marg + omegak*zetak)

        return muk_cond, sigmak_cond
dataset/ETHPy150Open HIPS/pgmult/pgmult/distributions.py/PGLogisticNormalMultinomial.conditional_psi/original