27 #include <Eigen/Dense>
57 const GaussianMixtureDistributionBasePtr& gmm2)
override
64 const GaussianMixtureComponent& comp2)
override
69 const float w1 = comp1.weight;
70 const float w2 = comp2.weight;
71 const float k = 1. / (w1 + w2);
72 const Eigen::VectorXf x1 = gaussian1->toEigenMean();
73 const Eigen::VectorXf x2 = gaussian2->toEigenMean();
74 const Eigen::MatrixXf p1 = gaussian1->toEigenCovariance();
75 const Eigen::MatrixXf p2 = gaussian2->toEigenCovariance();
76 const Eigen::VectorXf d = x1 - x2;
78 const Eigen::MatrixXf p12 = k * (w1 * p1 + w2 * p2 + k * w1 * w2 * d * d.transpose());
80 const float result = 0.5 * ((w1 + w2) * logf(p12.determinant()) -
81 w1 * logf(p1.determinant()) - w2 * logf(p2.determinant()));