17 uqFullEnvironment env;
18 uqVectorSpace<uqGslVector, uqGslMatrix> domainSpace(env,
"test_space", 2, NULL);
19 uqMap eMap(2, 0, env.comm());
21 uqGslVector domainMinVal(env, eMap, -1e30);
22 uqGslVector domainMaxVal(env, eMap, 1e30);
24 uqGaussianVectorPdf<uqGslVector, uqGslMatrix>* gaussianPdf;
25 double tolClose = 1e-13, tolSmall = 1e-16;
33 uqGslVector expectedVal(env, eMap, 0.0);
34 uqGslVector varianceVal(env, eMap, 1.0);
35 uqGslVector testValues(env, eMap, 0.0);
37 gaussianPdf =
new uqGaussianVectorPdf<uqGslVector, uqGslMatrix>(
"test_pdf", domainSpace, domainMinVal,
38 domainMaxVal, expectedVal, varianceVal);
40 testValues[0] = testValues[1] = 0.0;
41 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), 1.0, tolClose);
42 BOOST_REQUIRE_SMALL(gaussianPdf->minus2LnDensity(testValues), tolSmall);
44 testValues[0] = 1.0; testValues[1] = 1.0;
45 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
46 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
48 testValues[0] = 0.0; testValues[1] = 1.0;
49 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
50 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
52 testValues[0] = -1.0; testValues[1] = 1.0;
53 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
54 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
56 testValues[0] = -1.0; testValues[1] = 0.0;
57 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
58 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
60 testValues[0] = -1.0; testValues[1] = -1.0;
61 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
62 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
64 testValues[0] = 0.0; testValues[1] = -1.0;
65 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
66 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
68 testValues[0] = 1.0; testValues[1] = -1.0;
69 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
70 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
72 testValues[0] = 1.0; testValues[1] = 0.0;
73 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
74 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
79 varianceVal[0] = 0.25; varianceVal[1] = 0.5;
81 gaussianPdf =
new uqGaussianVectorPdf<uqGslVector, uqGslMatrix>(
"test_pdf", domainSpace, domainMinVal,
82 domainMaxVal, expectedVal, varianceVal);
84 testValues[0] = testValues[1] = 0.0;
85 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), 1.0, tolClose);
86 BOOST_REQUIRE_SMALL(gaussianPdf->minus2LnDensity(testValues), tolSmall);
88 testValues[0] = 1.0; testValues[1] = 1.0;
89 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-3.0), tolClose);
90 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 6.0 , tolClose);
92 testValues[0] = 0.0; testValues[1] = 1.0;
93 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
94 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
96 testValues[0] = -1.0; testValues[1] = 1.0;
97 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-3.0), tolClose);
98 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 6.0 , tolClose);
100 testValues[0] = -1.0; testValues[1] = 0.0;
101 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-2.0), tolClose);
102 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 4.0 , tolClose);
104 testValues[0] = -1.0; testValues[1] = -1.0;
105 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-3.0), tolClose);
106 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 6.0 , tolClose);
108 testValues[0] = 0.0; testValues[1] = -1.0;
109 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
110 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
112 testValues[0] = 1.0; testValues[1] = -1.0;
113 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-3.0), tolClose);
114 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 6.0 , tolClose);
116 testValues[0] = 1.0; testValues[1] = 0.0;
117 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-2.0), tolClose);
118 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 4.0 , tolClose);
121 expectedVal[0] = 1.0; expectedVal[1] = -0.5;
123 gaussianPdf->updateExpectedValues(expectedVal);
125 testValues[0] = 0.0; testValues[1] = 0.0;
126 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-2.25), tolClose);
127 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 4.5 , tolClose);
129 testValues[0] = 1.0; testValues[1] = 1.0;
130 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-2.25), tolClose);
131 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 4.5 , tolClose);
133 testValues[0] = 0.0; testValues[1] = 1.0;
134 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-4.25), tolClose);
135 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 8.5 , tolClose);
137 testValues[0] = -1.0; testValues[1] = 1.0;
138 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-10.25), tolClose);
139 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 20.5 , tolClose);
141 testValues[0] = -1.0; testValues[1] = 0.0;
142 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-8.25), tolClose);
143 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 16.5 , tolClose);
145 testValues[0] = -1.0; testValues[1] = -1.0;
146 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-8.25), tolClose);
147 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 16.5 , tolClose);
149 testValues[0] = 0.0; testValues[1] = -1.0;
150 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-2.25), tolClose);
151 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 4.5 , tolClose);
153 testValues[0] = 1.0; testValues[1] = -1.0;
154 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.25), tolClose);
155 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 0.5 , tolClose);
157 testValues[0] = 1.0; testValues[1] = 0.0;
158 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.25), tolClose);
159 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 0.5 , tolClose);
169 expectedVal[0] = expectedVal[1] = 0.0;
171 uqGslMatrix covMatrix(env, eMap, 1.0);
173 gaussianPdf =
new uqGaussianVectorPdf<uqGslVector, uqGslMatrix>(
"test_pdf", domainSpace, domainMinVal,
174 domainMaxVal, expectedVal, covMatrix);
176 testValues[0] = testValues[1] = 0.0;
177 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), 1.0, tolClose);
178 BOOST_REQUIRE_SMALL(gaussianPdf->minus2LnDensity(testValues), tolSmall);
180 testValues[0] = 1.0; testValues[1] = 1.0;
181 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
182 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
184 testValues[0] = 0.0; testValues[1] = 1.0;
185 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
186 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
188 testValues[0] = -1.0; testValues[1] = 1.0;
189 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
190 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
192 testValues[0] = -1.0; testValues[1] = 0.0;
193 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
194 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
196 testValues[0] = -1.0; testValues[1] = -1.0;
197 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
198 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
200 testValues[0] = 0.0; testValues[1] = -1.0;
201 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
202 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
204 testValues[0] = 1.0; testValues[1] = -1.0;
205 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
206 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
208 testValues[0] = 1.0; testValues[1] = 0.0;
209 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.5), tolClose);
210 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.0 , tolClose);
215 covMatrix(0,0) = 2.0; covMatrix(0,1) = 1.0;
216 covMatrix(1,0) = 1.0; covMatrix(1,1) = 2.0;
221 gaussianPdf->updateCovMatrix(covMatrix);
223 testValues[0] = testValues[1] = 0.0;
224 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), 1.0, tolClose);
225 BOOST_REQUIRE_SMALL(gaussianPdf->minus2LnDensity(testValues), tolSmall);
227 testValues[0] = 1.0; testValues[1] = 1.0;
228 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0/3.0), tolClose);
229 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0/3.0 , tolClose);
231 testValues[0] = 0.0; testValues[1] = 1.0;
232 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0/3.0), tolClose);
233 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0/3.0 , tolClose);
235 testValues[0] = -1.0; testValues[1] = 1.0;
236 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.0), tolClose);
237 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 2.0 , tolClose);
240 expectedVal[0] = 1.0; expectedVal[1] = -0.5;
242 gaussianPdf->updateExpectedValues(expectedVal);
244 testValues[0] = testValues[1] = 0.0;
245 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-5.833333333333333e-01), tolClose);
246 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.166666666666667e+00 , tolClose);
248 testValues[0] = 1.0; testValues[1] = 1.0;
249 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-0.75), tolClose);
250 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 1.5 , tolClose);
252 testValues[0] = 0.0; testValues[1] = 1.0;
253 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-1.583333333333333e+00), tolClose);
254 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 3.166666666666667e+00 , tolClose);
256 testValues[0] = -1.0; testValues[1] = 1.0;
257 BOOST_REQUIRE_CLOSE(gaussianPdf->actualDensity(testValues), std::exp(-3.083333333333333e+00), tolClose);
258 BOOST_REQUIRE_CLOSE(gaussianPdf->minus2LnDensity(testValues), 6.166666666666666e+00 , tolClose);