def expected_log_likelihood(self, mus, sigmas, y):
        """
        Compute the expected log likelihood for a mean and
        covariance of x and an observed value of y.
        """

        # Flatten the covariance
        T = mus.shape[0]
        D = self.D_in
        sigs_vec = sigmas.reshape((T, D ** 2))

        # Compute the log likelihood of each column
        ll = np.zeros((T, self.D_out))
        for n in range(self.D_out):

            an = self.A[n]

            E_loglmbda = np.dot(mus, an)
            ll[:,n] += y[:,n] * E_loglmbda

            # Vectorized log likelihood calculation
            aa_vec = np.outer(an, an).reshape((D ** 2,))
            ll[:,n] = -np.exp(E_loglmbda + 0.5 * np.dot(sigs_vec, aa_vec))

        return ll
def expected_log_likelihood ( self , mus , sigmas , y ) : T = mus . shape [ 0 ] D = self . D_in sigs_vec = sigmas . reshape ( ( T , D ** 2 ) ) ll = np . zeros ( ( T , self . D_out ) ) for n in range ( self . D_out ) : an = self . A [ n ] E_loglmbda = np . dot ( mus , an ) ll [ : , n ] += y [ : , n ] * E_loglmbda aa_vec = np . outer ( an , an ) . reshape ( ( D ** 2 , ) ) ll [ : , n ] = - np . exp ( E_loglmbda + 0.5 * np . dot ( sigs_vec , aa_vec ) ) return ll
Compute the expected log likelihood for a mean and
        covariance of x and an observed value of y.