9 #include <framework/utilities/ConditionalGaussGenerator.h>
10 #include <framework/utilities/MultivariateNormalGenerator.h>
13 #include <gtest/gtest.h>
22 class GaussGeneratorsTests :
public ::testing::Test {
26 virtual void SetUp() { }
29 virtual void TearDown() { }
34 TEST_F(GaussGeneratorsTests, Generator6DTest)
36 Eigen::MatrixXd cov(6, 6);
39 for (
int i = 0; i < 6; ++i)
40 for (
int j = 0; j < 6; ++j)
41 cov(i, j) = gRandom->Poisson(20) - 20;
44 cov *= cov.transpose();
47 Eigen::VectorXd mu(6);
48 mu << 3, 0, -2, 7, -5, -1;
55 Eigen::VectorXd muS = Eigen::VectorXd::Zero(6);
56 Eigen::MatrixXd covS = Eigen::MatrixXd::Zero(6, 6);
57 for (
int i = 0; i < N; ++i) {
59 Eigen::VectorXd x = gen.generate();
61 covS += (x - mu) * (x - mu).transpose() / N;
65 EXPECT_NEAR((muS - mu).squaredNorm(), 0.0, 1e-2);
66 EXPECT_NEAR((covS - cov).squaredNorm(), 0.0, 5e-2);
72 TEST_F(GaussGeneratorsTests, ConditionalGenerator2DTest)
75 Eigen::MatrixXd cov(2, 2);
80 Eigen::VectorXd mu(2);
88 Eigen::VectorXd muS = Eigen::VectorXd::Zero(2);
89 Eigen::MatrixXd covS = Eigen::MatrixXd::Zero(2, 2);
90 for (
int i = 0; i < N; ++i) {
92 double x0 = gRandom->Gaus(mu[0],
sqrt(cov(0, 0)));
95 Eigen::VectorXd x = gen.generate(x0);
97 covS += (x - mu) * (x - mu).transpose() / N;
101 EXPECT_NEAR((muS - mu).squaredNorm(), 0.0, 1e-3);
102 EXPECT_NEAR((covS - cov).squaredNorm(), 0.0, 1e-3);
107 TEST_F(GaussGeneratorsTests, ConditionalGenerator6DTest)
109 Eigen::MatrixXd cov(6, 6);
112 for (
int i = 0; i < 6; ++i)
113 for (
int j = 0; j < 6; ++j)
114 cov(i, j) = gRandom->Poisson(20) - 20;
117 cov *= cov.transpose();
120 Eigen::VectorXd mu(6);
121 mu << 3, 0, -2, 7, -5, -1;
128 Eigen::VectorXd muS = Eigen::VectorXd::Zero(6);
129 Eigen::MatrixXd covS = Eigen::MatrixXd::Zero(6, 6);
130 for (
int i = 0; i < N; ++i) {
132 double x0 = gRandom->Gaus(mu[0],
sqrt(cov(0, 0)));
135 Eigen::VectorXd x = gen.generate(x0);
137 covS += (x - mu) * (x - mu).transpose() / N;
141 EXPECT_NEAR((muS - mu).squaredNorm(), 0.0, 1e-2);
142 EXPECT_NEAR((covS - cov).squaredNorm(), 0.0, 5e-2);
Class implementing n-dimensional random number generator from Gaussian distribution where the first c...
Class to generate normal distributed, correlated random numbers given the mean values and the covaria...
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.