示例#1
0
void cGMM::condition(const GMM& gmm_in,const std::vector<std::size_t>& in,const std::vector<std::size_t>& out){

    //  std::cout<< "cGMM::condition independent x" << std::endl;

    std::size_t D_c = in.size();
    std::size_t K   = gmm_in.K;

    arma::colvec           weights(K);
    std::vector<arma::vec> Means(K);
    std::vector<arma::mat> Covariances(K);


    //  std::cout<< "K: " << K << std::endl;
    gaussian_c.resize(K);

    // gmm_in.get_means()[0].print("gmm_in.get_means()[0]");
    // gmm_in.get_covariances()[0].print("gmm_in.get_covariances()[0]");


    for(std::size_t k = 0; k < gmm_in.K;k++){
        // P( x_a | X_b)
        gaussian_c[k].condition(gmm_in.get_means()[k],gmm_in.get_covariances()[k],in,out);
        //   std::cout<< "after conidtion["<<0<<"]" << std::endl;

        Means[k].resize(D_c);
        Covariances[k] = gaussian_c[k].Sigma_1c2;
        // std::cout<< "after Covariances["<<k<<"]" << std::endl;

    }

    gmm_c = GMM(weights,Means,Covariances);

}
示例#2
0
double Information::lower_bound_entropy(GMM& gmm) {
    double HL = 0;
    double tmp = 0;
    for(unsigned int i = 0; i < gmm.K;i++){
        tmp = 0;
        for(unsigned int j = 0; j < gmm.K;j++){
            tmp = tmp + gmm.get_weigts()[i] *  mvnpdf(gmm.get_means()[i],gmm.get_means()[j],gmm.get_covariances()[i] + gmm.get_covariances()[j]);
        }
        tmp = log(tmp);
        HL = HL + gmm.get_weigts()[i] * tmp;
    }
    HL = -1*HL;
    HL = checkForNan(HL,qHl);

    return HL;
}