(self, logwts)
return mu, sigma
Compute the moments of the cluster mixture with logwts.
        Args:
            logwts: A K x 1 array of log cluster probabilities.
        Returns:
            mu: A (D,) mean vector.
            sigma: A D x D covariance matrix.
Compute the moments of the cluster mixture with logwts.
        Args:
            logwts: A K x 1 array of log cluster probabilities.
        Returns:
            mu: A (D,) mean vector.
            sigma: A D x D covariance matrix.
Compute the moments of the cluster mixture with logwts . Args : logwts : A K x 1 array of log cluster probabilities . Returns : mu : A ( D ) mean vector . sigma : A D x D covariance matrix .
def moments(self, logwts):
        """
        Compute the moments of the cluster mixture with logwts.
        Args:
            logwts: A K x 1 array of log cluster probabilities.
        Returns:
            mu: A (D,) mean vector.
            sigma: A D x D covariance matrix.
        """
        # Exponentiate.
        wts = np.exp(logwts)

        # Compute overall mean.
        mu = np.sum(self.mu * wts, axis=0)

        # Compute overall covariance.
        diff = self.mu - np.expand_dims(mu, axis=0)
        diff_expand = np.expand_dims(self.mu, axis=1) * \
                np.expand_dims(diff, axis=2)
        wts_expand = np.expand_dims(wts, axis=2)
        sigma = np.sum((self.sigma + diff_expand) * wts_expand, axis=0)
        return mu, sigma
def moments ( self , logwts ) : # Exponentiate. wts = np . exp ( logwts ) # Compute overall mean. mu = np . sum ( self . mu * wts , axis = 0 ) # Compute overall covariance. diff = self . mu - np . expand_dims ( mu , axis = 0 ) diff_expand = np . expand_dims ( self . mu , axis = 1 ) * np . expand_dims ( diff , axis = 2 ) wts_expand = np . expand_dims ( wts , axis = 2 ) sigma = np . sum ( ( self . sigma + diff_expand ) * wts_expand , axis = 0 ) return mu , sigma