double Information::upper_bound_entropy(GMM &gmm) { double HU = 0; for(unsigned int i = 0; i < gmm.K; i++){ HU = HU - gmm.get_weigts()[i]*log(gmm.get_weigts()[i]) + 0.5*gmm.get_weigts()[i] *log(std::pow(2*M_PI*exp(1),(double)gmm.D) * arma::det(gmm.get_covariances()[i])) ; //log(std::pow(2*M_PI*exp(1),(double)gmm.D) * arma::det(gmm.getSigma(i))) } HU = checkForNan(HU,qHu); return HU; }
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; }
void cGMM::condition(const arma::colvec& x_in, const GMM &gmm_in){ // std::cout<< "cGMM::condition dependent x" << std::endl; // x_in.print("x_in"); for(std::size_t k = 0; k < gmm_in.K;k++){ // \mu_a + Sig_12 * Sig_22^{-1} * (x - \mu_b) gaussian_c[k].mu_condition(x_in); gmm_c.set_mu(k,gaussian_c[k].Mean_c); gmm_c.set_prior(k,gmm_in.get_weigts()[k] * stats::mvnpdf(x_in,gaussian_c[k].Mu_2,gaussian_c[k].invSigma22,gaussian_c[k].det_22)); } gmm_c.set_prior( gmm_c.get_weigts() / arma::sum( gmm_c.get_weigts() + std::numeric_limits<double>::min()) ); }