Merge branch 'master' of https://git.frank-ebner.de/FHWS/Indoor
This commit is contained in:
@@ -18,10 +18,10 @@ class RandomGenerator : public std::minstd_rand {
|
||||
public:
|
||||
|
||||
/** ctor with default seed */
|
||||
RandomGenerator() : std::minstd_rand(RANDOM_SEED) {;}
|
||||
RandomGenerator() : std::minstd_rand(RANDOM_SEED) {;}
|
||||
|
||||
/** ctor with custom seed */
|
||||
RandomGenerator(result_type seed) : std::minstd_rand(seed) {;}
|
||||
RandomGenerator(result_type seed) : std::minstd_rand(seed) {;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Distribution {
|
||||
Assert::notEqual(numElements, 0, "data is empty, thats not enough for getting the distribution!");
|
||||
|
||||
const Eigen::MatrixXd centered = data.rowwise() - mean.transpose();
|
||||
const Eigen::MatrixXd cov = (centered.adjoint() * centered) / double(data.rows() - 1);
|
||||
Eigen::MatrixXd cov = (centered.adjoint() * centered) / double(data.rows() - 1);
|
||||
|
||||
return NormalDistributionN(mean, cov);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,13 @@ public:
|
||||
* @param Q is a vector containg the densities of the same samples set then P
|
||||
*/
|
||||
static inline Scalar getGeneralFromSamples(Eigen::VectorXd P, Eigen::VectorXd Q, LOGMODE mode){
|
||||
// normalize
|
||||
P /= P.sum();
|
||||
Q /= Q.sum();
|
||||
|
||||
Assert::isNear((double)P.sum(), 1.0, 0.01,"Normalization failed.. this shouldn't happen");
|
||||
Assert::isNear((double)Q.sum(), 1.0, 0.01, "Normalization failed.. this shouldn't happen");
|
||||
|
||||
Eigen::VectorXd M = 0.5 * (P + Q);
|
||||
|
||||
return (0.5 * KullbackLeibler<Scalar>::getGeneralFromSamples(P, M, mode)) + (0.5 * KullbackLeibler<Scalar>::getGeneralFromSamples(Q, M, mode));
|
||||
|
||||
Reference in New Issue
Block a user