30 #include <Eigen/Dense>
55 float getDistance(
const GaussianMixtureDistributionBasePtr& gmm1,
const GaussianMixtureDistributionBasePtr& gmm2)
override
60 float getDistance(
const GaussianMixtureComponent& comp1,
const GaussianMixtureComponent& comp2)
override
65 const float w1 = comp1.weight;
66 const float w2 = comp2.weight;
67 const float k = 1. / (w1 + w2);
68 const Eigen::VectorXf x1 = gaussian1->toEigenMean();
69 const Eigen::VectorXf x2 = gaussian2->toEigenMean();
70 const Eigen::MatrixXf p1 = gaussian1->toEigenCovariance();
71 const Eigen::MatrixXf p2 = gaussian2->toEigenCovariance();
72 const Eigen::VectorXf d = x1 - x2;
74 const Eigen::MatrixXf p12 = k * (w1 * p1 + w2 * p2 + k * w1 * w2 * d * d.transpose());
76 const float result = 0.5 * ((w1 + w2) * logf(p12.determinant()) -
77 w1 * logf(p1.determinant()) - w2 * logf(p2.determinant()));